Module: Deface::Applicator

Included in:
Override
Defined in:
lib/deface/applicator.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#compatible_with_end_selector?Boolean

Returns:

  • (Boolean)


91
92
93
# File 'lib/deface/applicator.rb', line 91

def compatible_with_end_selector?
  create_action_command.range_compatible?
end

#create_action_commandObject

Raises:



84
85
86
87
88
89
# File 'lib/deface/applicator.rb', line 84

def create_action_command
  commands = Rails.application.config.deface.actions
  command = commands.find { |command| command.to_sym == action }
  raise(DefaceError, "Action #{action} not found") unless command
  command.new(:source_element => safe_source_element, :attributes => attributes)
end

#execute_action(target_element) ⇒ Object



75
76
77
78
# File 'lib/deface/applicator.rb', line 75

def execute_action(target_element)
  validate_original(target_element)
  create_action_command.execute(target_element)
end

#execute_action_on_range(target_range) ⇒ Object



80
81
82
# File 'lib/deface/applicator.rb', line 80

def execute_action_on_range(target_range)
  create_action_command.execute_on_range(target_range)
end

#matcherObject



95
96
97
98
99
100
101
102
103
104
105
# File 'lib/deface/applicator.rb', line 95

def matcher
  if end_selector.blank?
    Deface::Matchers::Element.new(selector) # single css selector
  else
    unless compatible_with_end_selector?
      raise Deface::NotSupportedError, ":#{action} action does not support :closing_selector"
    end
    # targeting range of elements as end_selector is present
    Deface::Matchers::Range.new(name, selector, end_selector)
  end
end