Sha256: 89c6464753d6984955411f695487f9fb88de5deb7cbdf2aa16109403457da867

Contents?: true

Size: 795 Bytes

Versions: 29

Compression:

Stored size: 795 Bytes

Contents

# frozen_string_literal: true

class LHC::Response::Data
  autoload :Base, 'lhc/response/data/base'
  autoload :Item, 'lhc/response/data/item'
  autoload :Collection, 'lhc/response/data/collection'

  include LHC::Response::Data::Base

  def initialize(response, data: nil)
    @response = response
    @data = data

    if as_json.is_a?(Hash)
      @base = LHC::Response::Data::Item.new(response, data: data)
    elsif as_json.is_a?(Array)
      @base = LHC::Response::Data::Collection.new(response, data: data)
    end
  end

  def method_missing(method, *args, &block) # rubocop:disable Style/MethodMissingSuper
    @base.send(method, *args, &block)
  end

  def respond_to_missing?(method_name, include_private = false)
    @base.respond_to?(method_name, include_private) || super
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
lhc-12.1.1 lib/lhc/response/data.rb
lhc-12.1.0 lib/lhc/response/data.rb
lhc-12.0.3 lib/lhc/response/data.rb
lhc-12.0.2 lib/lhc/response/data.rb
lhc-12.0.1 lib/lhc/response/data.rb
lhc-12.0.0 lib/lhc/response/data.rb
lhc-11.2.0 lib/lhc/response/data.rb
lhc-11.1.1 lib/lhc/response/data.rb
lhc-11.1.0 lib/lhc/response/data.rb
lhc-11.0.2 lib/lhc/response/data.rb
lhc-11.0.1 lib/lhc/response/data.rb
lhc-11.0.0 lib/lhc/response/data.rb
lhc-10.5.4 lib/lhc/response/data.rb
lhc-10.5.3 lib/lhc/response/data.rb
lhc-10.5.2 lib/lhc/response/data.rb
lhc-10.5.1 lib/lhc/response/data.rb
lhc-10.5.0 lib/lhc/response/data.rb
lhc-10.4.3 lib/lhc/response/data.rb
lhc-10.4.2 lib/lhc/response/data.rb
lhc-10.4.1 lib/lhc/response/data.rb