class Stacktor::Core::Resource

Attributes

client[RW]
data[RW]

Public Class Methods

new(data, client, opts={}) click to toggle source
# File lib/stacktor/core/resource.rb, line 9
def initialize(data, client, opts={})
  @client = client
  self.handle_data(data, opts)
end

Public Instance Methods

[](field) click to toggle source
# File lib/stacktor/core/resource.rb, line 23
def [](field)
  @data[field.to_s] || @options[:headers][field.to_s]
end
[]=(field,val) click to toggle source
# File lib/stacktor/core/resource.rb, line 26
def []=(field,val)
  @data[field.to_s]=val
end
handle_data(data, opts={}) click to toggle source
# File lib/stacktor/core/resource.rb, line 14
def handle_data(data, opts={})
  if data.is_a?(String)
    data = JSON.parse(data)
  end
  @data = data || {}
  @options = opts
  @options[:headers] ||= {}
end
headers() click to toggle source
# File lib/stacktor/core/resource.rb, line 30
def headers
  @options[:headers]
end
method_missing(method, *args, &block) click to toggle source
# File lib/stacktor/core/resource.rb, line 34
def method_missing(method, *args, &block)
  return self[method]
end