Sha256: 567717f9c91dbff3d2e2e220630686098f0b5455e45aea930add24e8961ac822

Contents?: true

Size: 746 Bytes

Versions: 28

Compression:

Stored size: 746 Bytes

Contents

module Deface
  module Actions
    class AttributeAction < Action
      attr_reader :attributes

      def initialize(options = {})
        super options
        @attributes = options[:attributes]
        raise(DefaceError, "No attributes option specified") unless @attributes
      end

      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

      def normalize_attribute_name(name)
        name = name.to_s.gsub(/"|'/, '')

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

        name
      end

    end
  end
end

Version data entries

28 entries across 28 versions & 2 rubygems

Version Path
deface-1.9.0 lib/deface/actions/attribute_action.rb
deface-1.8.2 lib/deface/actions/attribute_action.rb
deface-1.8.1 lib/deface/actions/attribute_action.rb
deface-1.8.0 lib/deface/actions/attribute_action.rb
deface-1.7.0 lib/deface/actions/attribute_action.rb
deface-1.6.2 lib/deface/actions/attribute_action.rb
deface-1.6.1 lib/deface/actions/attribute_action.rb
deface-1.6.0 lib/deface/actions/attribute_action.rb
deface-1.5.3 lib/deface/actions/attribute_action.rb
deface-1.5.2 lib/deface/actions/attribute_action.rb
deface-1.5.1 lib/deface/actions/attribute_action.rb
deface-1.5.0 lib/deface/actions/attribute_action.rb
deface-1.4.0 lib/deface/actions/attribute_action.rb
deface-1.3.2 lib/deface/actions/attribute_action.rb
deface-1.3.1 lib/deface/actions/attribute_action.rb
deface-1.3.0 lib/deface/actions/attribute_action.rb
deface-1.2.0 lib/deface/actions/attribute_action.rb
deface-1.1.0 lib/deface/actions/attribute_action.rb
deface-1.0.2 lib/deface/actions/attribute_action.rb
solidus_backend-1.0.0.pre3 vendor/bundle/gems/deface-1.0.1/lib/deface/actions/attribute_action.rb