Module: Sumaki::Model::Associations::AccessorAdder::Singular
- Defined in:
- lib/sumaki/model/associations.rb
Overview
:nodoc:
Class Method Summary collapse
- .add(methods_module, reflections, reflection) ⇒ Object
- .add_builder(methods_module, name) ⇒ Object
- .add_getter(methods_module, name) ⇒ Object
Class Method Details
.add(methods_module, reflections, reflection) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/sumaki/model/associations.rb', line 17 def add(methods_module, reflections, reflection) add_getter(methods_module, reflection.name) add_builder(methods_module, reflection.name) reflections[reflection.name] = reflection end |
.add_builder(methods_module, name) ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/sumaki/model/associations.rb', line 34 def add_builder(methods_module, name) methods_module.module_eval " def build_\#{name}(attrs = {}) # def build_author(attrs = {})\n association(:\#{name}).build_model(attrs) # association(:author).build_model(attrs)\n end # end\n RUBY\nend\n", __FILE__, __LINE__ + 1 |
.add_getter(methods_module, name) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/sumaki/model/associations.rb', line 26 def add_getter(methods_module, name) methods_module.module_eval " def \#{name} # def author\n association(:\#{name}).model # association(:author).model\n end # end\n RUBY\nend\n", __FILE__, __LINE__ + 1 |