class BananaStand::Models::Base

Attributes

client[RW]

Public Class Methods

new(data, client = nil) click to toggle source
# File lib/banana_stand/models/base.rb, line 5
def initialize(data, client = nil)
  @data = data || {}

  @client = client if client.present?
end

Private Class Methods

resource_path() click to toggle source
# File lib/banana_stand/models/base.rb, line 29
def self.resource_path
  raise NotImplementedError, "resource_path must be implemented by derived models"
end

Public Instance Methods

delete!() click to toggle source
# File lib/banana_stand/models/base.rb, line 23
def delete!
  client.delete_resource("#{self.class.resource_path}/#{self.id}.json")
end
method_missing(method) click to toggle source
Calls superclass method
# File lib/banana_stand/models/base.rb, line 11
def method_missing(method)
  if @data[method.to_s].present?
    @data[method.to_s]
  else
    super
  end
end
respond_to?(method, include_private = false) click to toggle source
Calls superclass method
# File lib/banana_stand/models/base.rb, line 19
def respond_to?(method, include_private = false)
  @data[method.to_s].present? || super(method, include_private)
end