Sha256: a1bdc65030a3e890593c1e6e55a684da2f90c1601fe92bed887b035b051b8320

Contents?: true

Size: 1.01 KB

Versions: 1

Compression:

Stored size: 1.01 KB

Contents

module Attune
  module Model
    # Name value pairs indicating the context where a ranking will be displayed.
    #
    # @attr [String] name
    # @attr [String] value
    class ScopeEntry
      attr_accessor :name
      

      attr_accessor :value
      

      def initialize(attributes = {})
        return if attributes.empty?
        # Workaround since JSON.parse has accessors as strings rather than symbols
        @name = attributes["name"] || attributes[:"name"]
        # Workaround since JSON.parse has accessors as strings rather than symbols
        @value = attributes["value"] || attributes[:"value"]
        

      end

      def to_body
        Hash[ATTRIBUTE_MAP.map do |internal, external|
          next unless value = send(internal)
          [external, value]
        end.compact]
      end

      def to_json(options = {})
        to_body.to_json
      end

      private
      # :internal => :external
      ATTRIBUTE_MAP = {
          :name => :name,
          :value => :value

        }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
attune-1.0.6 lib/attune/models/scope_entry.rb