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 <<-RUBY, __FILE__, __LINE__ + 1
def #{name}
attribute('#{name}').read
end
def #{name}= value
attribute('#{name}').write(value)
end
def #{name}?
attribute('#{name}').query
end
def #{name}_before_type_cast
attribute('#{name}').read_before_type_cast
end
RUBY
end
|
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
|