logandk/mongoid_denormalize — pull request #7 by icambron (2012-04-05 10:48:55+00:00)
Title: added :as option

One issue I came across is that mongoid_denormalize doesn't respect `:inverse_of` in `to` denormalizations; it just assumes that the relationship on the other side is `class_name_field_name`. For example:

```rb
class User
include Mongoid::Document
include Mongoid::Denormalize

field :nickname
has_many :moderated_comments, :class_name => "Comment", :inverse_of => :moderator
denormalize :nickname, :to => :moderated_comments
end

class Comment
include Mongoid::Document
include Mongoid::Denormalize

belongs_to :moderator, :class_name => "User", :inverse_of => :moderated_comments
denormalize :nickname, :from => :moderator
end
```
will break trying to access `user_nickname` on a comment. In theory, I guess you could inspect the schema and figure out that we really wanted `moderator_nickname`, but I just added an as option, so it would be

```ruby
denormalize :nickname, :to => :moderated_comments, as => :moderator
```