Class: Howitzer::Web::SectionDsl::ClassMethods::SectionScope
- Inherits:
-
Object
- Object
- Howitzer::Web::SectionDsl::ClassMethods::SectionScope
- Defined in:
- lib/howitzer/web/section_dsl.rb
Overview
This class is for private usage only
Instance Attribute Summary collapse
-
#section_class ⇒ Object
Returns the value of attribute section_class.
Instance Method Summary collapse
-
#element(*args) ⇒ Object
# Defines an element on the section # @see Howitzer::PageDsl::ClassMethods#element.
-
#finder_args ⇒ Array
Returns a selector for the section.
-
#initialize(name, *args, &block) ⇒ SectionScope
constructor
Instantiates an anynomous or named section and executes block code in the section scope.
-
#section(name, *args, &block) ⇒ Object
Delegates a section describing to the section class.
Constructor Details
#initialize(name, *args, &block) ⇒ SectionScope
Instantiates an anynomous or named section and executes block code in the section scope
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/howitzer/web/section_dsl.rb', line 20 def initialize(name, *args, &block) @args = args self.section_class = if block Class.new(Howitzer::Web::BaseSection) else "#{name}_section".classify.constantize end instance_eval(&block) if block_given? end |
Instance Attribute Details
#section_class ⇒ Object
Returns the value of attribute section_class.
16 17 18 |
# File 'lib/howitzer/web/section_dsl.rb', line 16 def section_class @section_class end |
Instance Method Details
#element(*args) ⇒ Object
# Defines an element on the section # @see Howitzer::PageDsl::ClassMethods#element
34 35 36 |
# File 'lib/howitzer/web/section_dsl.rb', line 34 def element(*args) section_class.send(:element, *args) end |
#finder_args ⇒ Array
If anonymous section uses, then inline selector should be specified. Otherwise arguments should be defined with ‘.me` dsl method in named section
Returns a selector for the section.
50 51 52 53 54 55 |
# File 'lib/howitzer/web/section_dsl.rb', line 50 def finder_args @finder_args ||= begin return @args if @args.present? section_class.default_finder_args || raise(ArgumentError, 'Missing finder arguments') end end |
#section(name, *args, &block) ⇒ Object
Delegates a section describing to the section class
40 41 42 |
# File 'lib/howitzer/web/section_dsl.rb', line 40 def section(name, *args, &block) section_class.send(:section, name, *args, &block) end |