Module: ActiveData::Model::Associations::Reflections::Singular::ClassMethods
- Defined in:
- lib/active_data/model/associations/reflections/singular.rb
Instance Method Summary collapse
Instance Method Details
#generate_methods(name, target) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/active_data/model/associations/reflections/singular.rb', line 9 def generate_methods(name, target) super target.class_eval " def build_\#{name} attributes = {}\n association(:\#{name}).build(attributes)\n end\n\n def create_\#{name} attributes = {}\n association(:\#{name}).create(attributes)\n end\n\n def create_\#{name}! attributes = {}\n association(:\#{name}).create!(attributes)\n end\n RUBY\nend\n", __FILE__, __LINE__ + 1 |