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
7
8
9
|
# File 'lib/granite/form/model/attributes/reflections/attribute.rb', line 7
def self.attribute_class
Granite::Form::Model::Attributes::Attribute
end
|
.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 " 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\n def \#{name}_came_from_user?\n attribute('\#{name}').came_from_user?\n end\n\n def \#{name}_default\n attribute('\#{name}').default\n end\n\n def \#{name}_values\n attribute('\#{name}').enum.to_a\n end\n RUBY\nend\n", __FILE__, __LINE__ + 1
|
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
|