Skip to content

Added versioning (inline scheme) #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 13, 2012
Merged

Added versioning (inline scheme) #3

merged 4 commits into from
Mar 13, 2012

Conversation

dblock
Copy link
Collaborator

@dblock dblock commented Feb 29, 2012

You can specify the field version inline.

class Person
  include Mongoid::Document
  include Mongoid::CachedJson

  field :first
  field :last

  def name
    [ first, middle, last ].compact.join(" ")
  end

  json_fields \
    :first => { :versions => [ :v2, :v3 ] },
    :last => { :versions => [ :v2, :v3 ] },
    :middle => { :versions => [ :v2, :v3 ] },
    :born => { :versions => :v3 },
    :name => { :definition => :name }

end

The only limitation that I see is that you cannot change the definition of a field between versions.

@@ -98,6 +142,7 @@ You can define global transformations on all JSON values with `Mongoid::CachedJs

``` ruby
class Widget
include Monogid::Document
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: Mongoid::Document

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, glad you're reading the docs :)

dblock added a commit that referenced this pull request Mar 13, 2012
Added versioning (inline scheme)
@dblock dblock merged commit f5c2e7c into master Mar 13, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants