Module: HasControls
- Included in:
- Interview::Actionbar, Interview::Breadcrumbs, Interview::CollapseContainer, Interview::ConditionContainer, Interview::ContainerAttribute, Interview::Dropdown, Interview::Form, Interview::Grid, Interview::Link, Interview::List, Interview::MediaObject, Interview::Navigation, Interview::NavigationItem, Interview::NestedForm, Interview::Panel, Interview::Tab, Interview::TabBox, Interview::Text, Interview::View
- Defined in:
- lib/interview/has_controls.rb
Defined Under Namespace
Modules: ClassMethods
Instance Attribute Summary collapse
-
#controls ⇒ Object
readonly
Returns the value of attribute controls.
Class Method Summary collapse
Instance Method Summary collapse
- #add_control(control) {|control| ... } ⇒ Object
- #add_controls(controls) ⇒ Object
- #initialize(params = {}) ⇒ Object
- #siblings ⇒ Object
Instance Attribute Details
#controls ⇒ Object (readonly)
Returns the value of attribute controls.
3 4 5 |
# File 'lib/interview/has_controls.rb', line 3 def controls @controls end |
Class Method Details
.included(mod) ⇒ Object
31 32 33 |
# File 'lib/interview/has_controls.rb', line 31 def self.included(mod) mod.extend ClassMethods end |
Instance Method Details
#add_control(control) {|control| ... } ⇒ Object
10 11 12 13 14 |
# File 'lib/interview/has_controls.rb', line 10 def add_control(control, &block) control.parent = self yield(control) if block_given? @controls << control end |
#add_controls(controls) ⇒ Object
16 17 18 19 |
# File 'lib/interview/has_controls.rb', line 16 def add_controls(controls) controls.each { |control| control.parent = self } @controls += controls end |
#initialize(params = {}) ⇒ Object
5 6 7 8 |
# File 'lib/interview/has_controls.rb', line 5 def initialize(params={}) super @controls = self.class.definition.build_controls_for self end |
#siblings ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/interview/has_controls.rb', line 21 def siblings return @controls.map do |control| if control.respond_to? :siblings [control] + control.siblings else control end end.flatten end |