Module: Yammy
- Included in:
- Base
- Defined in:
- lib/yammy.rb
Defined Under Namespace
Classes: Base
Instance Method Summary collapse
Instance Method Details
#has_many(model, opts = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/yammy.rb', line 5 def has_many model, opts = {} field = opts[:as] || model.to_s.downcase.pluralize with = opts[:with] || nil model = model.to_s.singularize class_eval do define_method field do fields = instance_variable_get "@#{field}" collection_from_array fields, model, with end end end |