Class: JsonSchemaClient::Resource

Inherits:
Object
  • Object
show all
Defined in:
lib/json_schema_client/resource.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data, schema, entry_point, response = nil) ⇒ Resource

Returns a new instance of Resource.



20
21
22
23
24
25
# File 'lib/json_schema_client/resource.rb', line 20

def initialize(data, schema, entry_point, response = nil)
  @data         = OpenStruct.new(data)
  @schema       = schema
  @entry_point  = entry_point
  @response     = response
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args, &block) ⇒ Object



27
28
29
# File 'lib/json_schema_client/resource.rb', line 27

def method_missing(method_name, *args, &block)
  @data.send(method_name, *args, &block) || super
end

Instance Attribute Details

#dataObject (readonly)

Returns the Resource data.



9
10
11
# File 'lib/json_schema_client/resource.rb', line 9

def data
  @data
end

#responseObject (readonly)

Returns the HTTP response object for the Resource.



18
19
20
# File 'lib/json_schema_client/resource.rb', line 18

def response
  @response
end

#schemaObject (readonly)

Returns the Resource Schema.



12
13
14
# File 'lib/json_schema_client/resource.rb', line 12

def schema
  @schema
end