Class: Id::Model::Association
- Inherits:
-
Field
- Object
- Field
- Id::Model::Association
show all
- Defined in:
- lib/id/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, #key, #optional?, #presence_of, #value_of
Instance Method Details
#hierarchy ⇒ Object
17
18
19
|
# File 'lib/id/model/association.rb', line 17
def hierarchy
@hierarchy ||= Hierarchy.new(model.name, inferred_class_name)
end
|
#inferred_class ⇒ Object
9
10
11
|
# File 'lib/id/model/association.rb', line 9
def inferred_class
hierarchy.parent.const_get(inferred_class_name)
end
|
#inferred_class_name ⇒ Object
13
14
15
|
# File 'lib/id/model/association.rb', line 13
def inferred_class_name
@inferred_class_name ||= name.to_s.classify
end
|
#type ⇒ Object
5
6
7
|
# File 'lib/id/model/association.rb', line 5
def type
options.fetch(:type) { inferred_class }
end
|