Class: KirguduBase::DynamicFilters::ObligatoryFilterBuilder

Inherits:
KirguduBase::DynamicPages::Builder show all
Defined in:
app/models/kirgudu_base/dynamic_filters/obligatory_filter_builder.rb

Instance Method Summary collapse

Methods inherited from KirguduBase::DynamicPages::Builder

#build_element, #builder_options, #valiadte_interger_parameter, #valiadte_interger_positive_parameter, #validate_empty_parameter, #validate_generated_element, #validate_string_or_symbol_parameter, #validate_string_parameter, #validate_symbol_parameter

Constructor Details

#initialize(name, &block) ⇒ ObligatoryFilterBuilder



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'app/models/kirgudu_base/dynamic_filters/obligatory_filter_builder.rb', line 5

def initialize(name, &block)

  self.builder_options.merge!(
    {
      name: nil,
      source_method: nil,
        only: nil,
        skip: nil
    }
  )

  self.name(name)
  super(&block)
end

Instance Method Details

#only(value) ⇒ Object



24
25
26
# File 'app/models/kirgudu_base/dynamic_filters/obligatory_filter_builder.rb', line 24

def only(value)
  self.builder_options[:only] = value
end

#skip(value) ⇒ Object



28
29
30
# File 'app/models/kirgudu_base/dynamic_filters/obligatory_filter_builder.rb', line 28

def skip(value)
  self.builder_options[:skip] = value
end

#source_method(value) ⇒ Object



20
21
22
# File 'app/models/kirgudu_base/dynamic_filters/obligatory_filter_builder.rb', line 20

def source_method(value)
  self.builder_options[:source_method] = value
end

#to_filterObject



32
33
34
35
36
37
# File 'app/models/kirgudu_base/dynamic_filters/obligatory_filter_builder.rb', line 32

def to_filter
  element = ::KirguduBase::DynamicFilters::ObligatoryFilter.new
  self.build_element(element)
  self.validate_generated_element(element)
  element
end