Sha256: 94cbcca2cbadea5f180c3aa711acdd27523001be2b69934392fe222f2fefba31

Contents?: true

Size: 519 Bytes

Versions: 5

Compression:

Stored size: 519 Bytes

Contents

# frozen_string_literal: true

module HappyMapper
  class Attribute < Item
    attr_accessor :default

    # @see Item#initialize
    # Additional options:
    #   :default => Object The default value for this
    def initialize(name, type, options = {})
      super
      self.default = options[:default]
    end

    def find(node, _namespace, xpath_options)
      if options[:xpath]
        yield(node.xpath(options[:xpath], xpath_options))
      else
        yield(node.attributes[tag])
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
nokogiri-happymapper-0.10.0 lib/happymapper/attribute.rb
nokogiri-happymapper-0.9.0 lib/happymapper/attribute.rb
nokogiri-happymapper-0.8.1 lib/happymapper/attribute.rb
nokogiri-happymapper-0.8.0 lib/happymapper/attribute.rb
nokogiri-happymapper-0.7.0 lib/happymapper/attribute.rb