Class: Sunrise::Config::Field
Instance Attribute Summary collapse
Attributes inherited from Base
#abstract_model, #name, #parent
Instance Method Summary
collapse
#evaluate_method
Methods inherited from Base
register_class_option, register_instance_option, #register_instance_option
Constructor Details
#initialize(abstract_model, parent, options = {}) ⇒ Field
Returns a new instance of Field.
14
15
16
17
18
19
20
21
22
|
# File 'lib/sunrise/config/field.rb', line 14
def initialize(abstract_model, parent, options = {})
options = {:multiply => false, :sort => false}.merge(options)
super(abstract_model, parent, options)
@if_condition = options.delete(:if)
@unless_condition = options.delete(:unless)
end
|
Instance Attribute Details
#if_condition ⇒ Object
The condition that must be met on an object
9
10
11
|
# File 'lib/sunrise/config/field.rb', line 9
def if_condition
@if_condition
end
|
#unless_condition ⇒ Object
The condition that must not be met on an object
12
13
14
|
# File 'lib/sunrise/config/field.rb', line 12
def unless_condition
@unless_condition
end
|
Instance Method Details
#association? ⇒ Boolean
44
45
46
|
# File 'lib/sunrise/config/field.rb', line 44
def association?
input_options[:association] === true
end
|
#dom_id ⇒ Object
56
57
58
|
# File 'lib/sunrise/config/field.rb', line 56
def dom_id
@dom_id ||= "#{name}_field"
end
|
#html_options ⇒ Object
36
37
38
39
40
41
42
|
# File 'lib/sunrise/config/field.rb', line 36
def html_options
css = ["padder"]
css << "grey-but" if input_options[:boolean]
css << "tags-edit" if association?
{:class => css, :id => dom_id}.merge(input_options[:html] || {})
end
|
#human_name ⇒ Object
32
33
34
|
# File 'lib/sunrise/config/field.rb', line 32
def human_name
@config_options[:label] || abstract_model.model.human_attribute_name(@name)
end
|
28
29
30
|
# File 'lib/sunrise/config/field.rb', line 28
def input_options
@config_options.dup
end
|
#label? ⇒ Boolean
48
49
50
|
# File 'lib/sunrise/config/field.rb', line 48
def label?
@config_options[:label] != false
end
|
#nested? ⇒ Boolean
52
53
54
|
# File 'lib/sunrise/config/field.rb', line 52
def nested?
false
end
|
#visible?(object = nil) ⇒ Boolean
24
25
26
|
# File 'lib/sunrise/config/field.rb', line 24
def visible?(object = nil)
object.nil? || matches_conditions?(object)
end
|