0.0
No release in over 3 years
Low commit activity in last 3 years
Helpers to denormalize fields easily on mongo mapper models
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 0.15.0
 Project Readme

denormalize_mm

Easily Denormalize fields and associations without writing lots of custom before_validations_

Examples:

Initializer - config/initializers/mongo_mapper.rb:

  require 'mongo_mapper/denormalization'

Denormalizing a field:

class Employer
  include MongoMapper::Document

  key :name
end

class Employee
  include MongoMapper::Document
  include MongoMapper::Denormalization

  key :employer_name, String

  denormalize_field :employer, :name
  # or:
  # denormalize_field :employer, :name, :target_field => :employer_name
end

Denormalizing an association:

class Survey
  include MongoMapper::Document

  has_many :survey_questions
  has_many :survey_responses
end

class SurveyQuestion
  include MongoMapper::Document

  belongs_to :survey
end

class SurveyResponseOption
  include MongoMapper::Document
  include MongoMapper::Denormalization

  belongs_to :survey
  belongs_to :survey_question

  denormalize_association :survey, :from => :survey_question
end