Module: MagnumPI::API

Defined in:
lib/magnum-pi/api.rb,
lib/magnum-pi/api/scheme.rb,
lib/magnum-pi/api/consumer.rb,
lib/magnum-pi/api/instance.rb,
lib/magnum-pi/api/resources.rb,
lib/magnum-pi/api/inheritance.rb

Defined Under Namespace

Modules: Consumer, Inheritance, Instance Classes: Resources, Scheme

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'lib/magnum-pi/api.rb', line 10

def self.extended(base)
  if base.is_a? Class
    base.extend Inheritance
    base.send :include, Instance
    base.send :include, Consumer
  else
    base.extend Consumer
  end
end

Instance Method Details

#api(&block) ⇒ Object



20
21
22
23
24
25
26
27
# File 'lib/magnum-pi/api.rb', line 20

def api(&block)
  @api ||= Scheme.new
  if block_given?
    @api.instance_eval &block
  else
    @api
  end
end

#resources(&block) ⇒ Object



29
30
31
32
33
34
35
36
# File 'lib/magnum-pi/api.rb', line 29

def resources(&block)
  @resources ||= Resources.new
  if block_given?
    @resources.instance_eval &block
  else
    @resources
  end
end