Sha256: 65ab669bba5563ddd8d06ef70fc339693593563de836af487039bfdbc6e466a7

Contents?: true

Size: 465 Bytes

Versions: 3

Compression:

Stored size: 465 Bytes

Contents

module HappyMapper
  class Attribute < Item
    attr_accessor :default

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

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
blockscore-happymapper-0.6.2 lib/happymapper/attribute.rb
blockscore-happymapper-0.6.1 lib/happymapper/attribute.rb
blockscore-happymapper-0.6.0 lib/happymapper/attribute.rb