class Drip::Resource

Attributes

attributes[R]
raw_attributes[R]

Public Class Methods

new(raw_data = {}) click to toggle source
# File lib/drip/resource.rb, line 9
def initialize(raw_data = {})
  @raw_attributes = raw_data.dup.freeze
  @attributes = process(@raw_attributes)
end
resource_name() click to toggle source
# File lib/drip/resource.rb, line 14
def self.resource_name
  "resource"
end

Public Instance Methods

method_missing(method_name, *args, &block) click to toggle source
Calls superclass method
# File lib/drip/resource.rb, line 26
def method_missing(method_name, *args, &block)
  attributes.keys.include?(method_name.to_s) ? attributes[method_name.to_s] : super
end
respond_to?(method_name, include_private = false) click to toggle source
Calls superclass method
# File lib/drip/resource.rb, line 22
def respond_to?(method_name, include_private = false)
  attributes.keys.include?(method_name.to_s) || super
end
singular?() click to toggle source
# File lib/drip/resource.rb, line 18
def singular?
  true
end

Private Instance Methods

process(attributes) click to toggle source
# File lib/drip/resource.rb, line 32
def process(attributes)
  {}.tap do |attrs|
    attributes.keys.each do |key|
      attrs[key] = process_attribute(key, attributes[key])
    end
  end
end
process_attribute(key, raw_value) click to toggle source
# File lib/drip/resource.rb, line 40
def process_attribute(key, raw_value)
  if key.to_s =~ /_at$/ # auto-coerce times
    raw_value ? Time.parse(raw_value) : nil
  else
    raw_value
  end
end