Class: Granite::Form::Model::Attributes::Reflections::ReferenceOne
- Inherits:
-
Base
- Object
- Base
- Granite::Form::Model::Attributes::Reflections::ReferenceOne
show all
- Defined in:
- lib/granite/form/model/attributes/reflections/reference_one.rb
Instance Attribute Summary
Attributes inherited from Base
#name, #options
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
attribute_class, build, #build_attribute, #enum, #initialize, #keys, #readonly, #type
Class Method Details
.generate_methods(name, target) ⇒ Object
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/granite/form/model/attributes/reflections/reference_one.rb', line 7
def self.generate_methods(name, target)
target.class_eval " def \#{name}\n attribute('\#{name}').read\n end\n\n def \#{name}= value\n attribute('\#{name}').write(value)\n end\n\n def \#{name}?\n attribute('\#{name}').query\n end\n\n def \#{name}_before_type_cast\n attribute('\#{name}').read_before_type_cast\n end\n RUBY\nend\n", __FILE__, __LINE__ + 1
|
Instance Method Details
#association ⇒ Object
31
32
33
|
# File 'lib/granite/form/model/attributes/reflections/reference_one.rb', line 31
def association
@association ||= options[:association].to_s
end
|
#inspect_reflection ⇒ Object
27
28
29
|
# File 'lib/granite/form/model/attributes/reflections/reference_one.rb', line 27
def inspect_reflection
"#{name}: (reference)"
end
|