Class: Trestle::Attribute::Association
- Inherits:
-
Trestle::Attribute
- Object
- Trestle::Attribute
- Trestle::Attribute::Association
- Defined in:
- lib/trestle/attribute.rb
Instance Attribute Summary
Attributes inherited from Trestle::Attribute
Instance Method Summary collapse
- #association_class ⇒ Object
- #association_name ⇒ Object
-
#initialize(name, options = {}) ⇒ Association
constructor
A new instance of Association.
- #polymorphic? ⇒ Boolean
Methods inherited from Trestle::Attribute
Constructor Details
#initialize(name, options = {}) ⇒ Association
Returns a new instance of Association.
14 15 16 |
# File 'lib/trestle/attribute.rb', line 14 def initialize(name, ={}) super(name, :association, ) end |
Instance Method Details
#association_class ⇒ Object
22 23 24 |
# File 'lib/trestle/attribute.rb', line 22 def association_class [:class].respond_to?(:call) ? [:class].call : [:class] end |
#association_name ⇒ Object
18 19 20 |
# File 'lib/trestle/attribute.rb', line 18 def association_name [:name] || name.to_s.sub(/_id$/, "") end |
#polymorphic? ⇒ Boolean
26 27 28 |
# File 'lib/trestle/attribute.rb', line 26 def polymorphic? [:polymorphic] == true end |