Class: Interview::Control
- Inherits:
-
Object
- Object
- Interview::Control
show all
- Includes:
- Draper::ViewHelpers
- Defined in:
- lib/interview/control.rb
Direct Known Subclasses
Actionbar, Attribute, Breadcrumbs, CollapseContainer, ConditionContainer, Dropdown, Form, FormErrors, Grid, HtmlControl, ImageLightBox, Link, List, MediaObject, Navigation, NestedForm, NestedFormAddLink, NestedFormRemoveLink, Panel, PolymorphicAddLink, SearchForm, Space, Tab, TabBox, Text, Tooltip, Tree, View
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(params = {}) ⇒ Control
Returns a new instance of Control.
7
8
9
10
|
# File 'lib/interview/control.rb', line 7
def initialize(params={})
set_attributes(params)
set_defaults
end
|
Instance Attribute Details
#parent ⇒ Object
Returns the value of attribute parent.
5
6
7
|
# File 'lib/interview/control.rb', line 5
def parent
@parent
end
|
Class Method Details
.build(opts = {}) ⇒ Object
62
63
64
|
# File 'lib/interview/control.rb', line 62
def self.build(opts={})
return @definition.build(opts)
end
|
.definition ⇒ Object
58
59
60
|
# File 'lib/interview/control.rb', line 58
def self.definition
return @definition
end
|
.inherited(subclass) ⇒ Object
66
67
68
69
70
|
# File 'lib/interview/control.rb', line 66
def self.inherited(subclass)
new_def = @definition.deep_dup
new_def.klass = subclass.name.underscore.to_sym
subclass.instance_variable_set :@definition, new_def
end
|
Instance Method Details
#ancestors ⇒ Object
29
30
31
32
33
34
35
|
# File 'lib/interview/control.rb', line 29
def ancestors
if @parent.nil?
return []
else
return [@parent] + @parent.ancestors
end
end
|
#find_attribute(attribute) ⇒ Object
37
38
39
40
41
42
43
44
|
# File 'lib/interview/control.rb', line 37
def find_attribute(attribute)
return nil if @parent.nil?
if @parent.respond_to? attribute
return @parent.send attribute
else
return @parent.find_attribute attribute
end
end
|
#find_attribute!(attr_name) ⇒ Object
46
47
48
49
50
|
# File 'lib/interview/control.rb', line 46
def find_attribute!(attr_name)
attribute = find_attribute(attr_name)
throw "Attribute #{attr_name} was not found." if attribute.nil?
return attribute
end
|
#render ⇒ Object
52
53
54
|
# File 'lib/interview/control.rb', line 52
def render
return ''
end
|
#set_attributes(params = {}) ⇒ Object
12
13
14
15
16
17
18
19
|
# File 'lib/interview/control.rb', line 12
def set_attributes(params={})
params.each do |key, value|
key = "#{key}=".to_sym
if respond_to?(key) send(key, value)
end
end
end
|
#set_defaults ⇒ Object
21
22
23
24
25
26
27
|
# File 'lib/interview/control.rb', line 21
def set_defaults
if self.class.const_defined? 'DEFAULTS'
self.class::DEFAULTS.each do |key, value|
self.send("#{key}=".to_sym, value)
end
end
end
|