class Howitzer::Web::SectionDsl::ClassMethods::SectionScope
This class is for private usage only
Attributes
section_class[RW]
Public Class Methods
new(name, *args, **options, &block)
click to toggle source
Instantiates an anynomous or named section and executes block code in the section scope
# File lib/howitzer/web/section_dsl.rb, line 22 def initialize(name, *args, **options, &block) @args = args @options = options self.section_class = if block Class.new(Howitzer::Web::BaseSection) else "#{name}_section".classify.constantize end instance_eval(&block) if block_given? end
Public Instance Methods
element(*args, **options)
click to toggle source
Defines an element on the section @see Howitzer::Web::ElementDsl::ClassMethods#element
# File lib/howitzer/web/section_dsl.rb, line 37 def element(*args, **options) section_class.send(:element, *args, **options) end
finder_args()
click to toggle source
Returns selector arguments for the section. @note If anonymous section uses, then inline selector should be specified.
Otherwise arguments should be defined with `.me` dsl method in named section
@return [Array] @raise [ArgumentError] when finder arguments were not specified
# File lib/howitzer/web/section_dsl.rb, line 53 def finder_args return @args if @args.present? @finder_args ||= (section_class.default_finder_args || raise(ArgumentError, 'Missing finder arguments')) end
finder_options()
click to toggle source
Returns selector options for the section. @note If anonymous section uses, then inline selector should be specified.
Otherwise arguments should be defined with `.me` dsl method in named section
@return [Array] @raise [ArgumentError] when finder arguments were not specified
# File lib/howitzer/web/section_dsl.rb, line 65 def finder_options @options.presence || section_class.default_finder_options || {} end
section(name, *args, **options, &block)
click to toggle source
Delegates a section describing to the section class
# File lib/howitzer/web/section_dsl.rb, line 43 def section(name, *args, **options, &block) section_class.send(:section, name, *args, **options, &block) end