Class: Granite::Form::Model::Attributes::Reflections::Attribute
- Inherits:
-
Base
- Object
- Base
- Granite::Form::Model::Attributes::Reflections::Attribute
show all
- Defined in:
- lib/granite/form/model/attributes/reflections/attribute.rb
Instance Attribute Summary
Attributes inherited from Base
#name, #options
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
build, #build_attribute, #enum, #initialize, #inspect_reflection, #keys, #readonly, #type
Class Method Details
.attribute_class ⇒ Object
.generate_methods(name, target) ⇒ Object
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/granite/form/model/attributes/reflections/attribute.rb', line 11
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
def #{name}_came_from_user?
attribute('#{name}').came_from_user?
end
def #{name}_default
attribute('#{name}').default
end
def #{name}_values
attribute('#{name}').enum.to_a
end
RUBY
end
|
Instance Method Details
#defaultizer ⇒ Object
43
44
45
|
# File 'lib/granite/form/model/attributes/reflections/attribute.rb', line 43
def defaultizer
@defaultizer ||= options[:default]
end
|
#normalizers ⇒ Object
47
48
49
|
# File 'lib/granite/form/model/attributes/reflections/attribute.rb', line 47
def normalizers
@normalizers ||= Array.wrap(options[:normalize] || options[:normalizer] || options[:normalizers])
end
|