Class: Structural::Model::Association
- Inherits:
-
Field
- Object
- Field
- Structural::Model::Association
show all
- Defined in:
- lib/structural/model/association.rb
Defined Under Namespace
Classes: Hierarchy
Instance Attribute Summary
Attributes inherited from Field
#model, #name, #options
Instance Method Summary
collapse
Methods inherited from Field
#cast, #default, #default?, #default_value, #define, #hook_define, #initialize, #ivar_name, #key, #presence_of, #value_of
Instance Method Details
#hierarchy ⇒ Object
16
17
18
|
# File 'lib/structural/model/association.rb', line 16
def hierarchy
@hierarchy ||= Hierarchy.new(model.name, inferred_class_name)
end
|
#inferred_class ⇒ Object
8
9
10
|
# File 'lib/structural/model/association.rb', line 8
def inferred_class
hierarchy.parent.const_get(inferred_class_name)
end
|
#inferred_class_name ⇒ Object
12
13
14
|
# File 'lib/structural/model/association.rb', line 12
def inferred_class_name
@inferred_class_name ||= name.to_s.classify
end
|
#type ⇒ Object
4
5
6
|
# File 'lib/structural/model/association.rb', line 4
def type
options.fetch(:type) { inferred_class }
end
|