class Deface::Actions::AttributeAction

Attributes

attributes[R]

Public Class Methods

new(options = {}) click to toggle source
Calls superclass method Deface::Actions::Action::new
# File lib/deface/actions/attribute_action.rb, line 6
def initialize(options = {})
  super options
  @attributes = options[:attributes]
  raise(DefaceError, "No attributes option specified") unless @attributes
end

Public Instance Methods

execute(target_element) click to toggle source
# File lib/deface/actions/attribute_action.rb, line 12
def execute(target_element)
  target_element = target_element.first
  attributes.each do |name, value|
    execute_for_attribute(target_element, normalize_attribute_name(name), value)
  end
end

Protected Instance Methods

normalize_attribute_name(name) click to toggle source
# File lib/deface/actions/attribute_action.rb, line 21
def normalize_attribute_name(name)
  name = name.to_s.gsub(/"|'/, '')

  if /\Adata-erb-/ =~ name
    name.gsub!(/\Adata-erb-/, '')
  end

  name
end