Sha256: 609701162d1aedf99c8f96f78a16efc381b1820ab5e7bfee525f625df1edb2a6

Contents?: true

Size: 525 Bytes

Versions: 2

Compression:

Stored size: 525 Bytes

Contents

# frozen_string_literal: true

module Theone
  # Base class to provide access to the json data
  class Base
    attr_reader :attributes, :client

    def initialize(client, json)
      @client = client
      @attributes = json
    end

    def method_missing(att, *_args, &_block)
      return attributes["_id"] if att == :id

      attributes.key?(att.to_s) ? attributes[att.to_s] : super
    end

    def respond_to_missing?(att, _)
      att = :_id if att == :id
      attributes.key?(att.to_s) || super
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
juggy-theone-sdk-0.1.1 lib/theone/base.rb
juggy-theone-sdk-0.1.0 lib/theone/base.rb