Module: Rapidash::Resourceable

Included in:
Base, Client
Defined in:
lib/rapidash/resourceable.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



3
4
5
# File 'lib/rapidash/resourceable.rb', line 3

def self.included(base)
  base.extend ClassMethods
end

Instance Method Details

#resource(name, id = nil, options = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/rapidash/resourceable.rb', line 7

def resource(name, id = nil, options = {})
  options[:url] ||= name
  if self.respond_to?(:url)
    options = {:previous_url => self.url}.merge!(options)
  end
  client = self
  client = self.client if self.respond_to?(:client)
  Rapidash::Base.new(client, id, options)
end

#resource!(*args) ⇒ Object



17
18
19
# File 'lib/rapidash/resourceable.rb', line 17

def resource!(*args)
  self.resource(*args).call!
end