Sha256: 4d1f67969bbe9ed0080c98df04c5dec849817de68b6f18486aa514bd6b60f184

Contents?: true

Size: 887 Bytes

Versions: 1

Compression:

Stored size: 887 Bytes

Contents

class EndecaOnDemand::Response::Dimension::DimensionValue < EndecaOnDemand::Proxy

  include EndecaOnDemand::PP

  def inspect_attributes; [ :options ]; end

  ## fields ##

  attr_reader :dimension, :options

  def initialize(dimension, xml)
    @dimension, @xml = dimension, xml
  end

  ## override proxy ##

  def class
    EndecaOnDemand::Response::Dimension::DimensionValue
  end

  # def inspection
  #   options.sort_by(&:first).map { |k,v| "#{k}: #{v.inspect}" }
  # end

  def inspection
    Hash[*options.sort_by(&:first).flatten]
  end

  ##

  ## data ##

  def options
    xml.children.inject({}) do |hash,child|
      hash.tap do
        hash[child.name] = child.content
      end
    end.symbolize_keys
  end

  ##

  protected

  def method_missing(method, *args, &block)
    return options[method] if options.has_key?(method)
    super(method, *args, &block)
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
endeca_on_demand-1.2.0 lib/endeca_on_demand/response/dimension/dimension_value.rb