Module: DCA::Models::Binder::ClassMethods
- Defined in:
- lib/dca/models/binder.rb
Instance Method Summary collapse
- #associations(complex = false) ⇒ Object
- #binder(name = :nokogiri) ⇒ Object
- #has_many(field, *args) ⇒ Object
- #has_one(field, *args) ⇒ Object
- #inherited(child) ⇒ Object
Instance Method Details
#associations(complex = false) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/dca/models/binder.rb', line 25 def associations complex = false @associations ||= {} return associations.select { |field, | !COMPLEX_TYPE.include?([:type]) } if complex @associations end |
#binder(name = :nokogiri) ⇒ Object
9 10 11 |
# File 'lib/dca/models/binder.rb', line 9 def binder name = :nokogiri @binder ||= "DCA::Models::#{name.to_s.camelize}Binder".constantize end |
#has_many(field, *args) ⇒ Object
19 20 21 22 23 |
# File 'lib/dca/models/binder.rb', line 19 def has_many field, *args = args. type = args.first add_association field, :many, type, end |
#has_one(field, *args) ⇒ Object
13 14 15 16 17 |
# File 'lib/dca/models/binder.rb', line 13 def has_one field, *args = args. type = args.first add_association field, :one, type, end |
#inherited(child) ⇒ Object
33 34 35 |
# File 'lib/dca/models/binder.rb', line 33 def inherited(child) associations.each { |field, | child.associations[field] = } end |