Class: DocSmoosher::Api

Inherits:
ApiObject show all
Defined in:
lib/doc_smoosher/api.rb

Instance Attribute Summary collapse

Attributes inherited from ApiObject

#default, #description, #example, #name, #required, #type

Attributes included from Parameters

#parameters

Instance Method Summary collapse

Methods included from Parameters

#parameter

Constructor Details

#initialize(params = {}, &block) ⇒ Api

Returns a new instance of Api.



39
40
41
# File 'lib/doc_smoosher/api.rb', line 39

def initialize(params = {}, &block)
  super(params)
end

Instance Attribute Details

#endpointObject

Returns the value of attribute endpoint.



3
4
5
# File 'lib/doc_smoosher/api.rb', line 3

def endpoint
  @endpoint
end

#formatObject

Returns the value of attribute format.



3
4
5
# File 'lib/doc_smoosher/api.rb', line 3

def format
  @format
end

#objectsObject

Returns the value of attribute objects.



3
4
5
# File 'lib/doc_smoosher/api.rb', line 3

def objects
  @objects
end

#resourcesObject

Returns the value of attribute resources.



3
4
5
# File 'lib/doc_smoosher/api.rb', line 3

def resources
  @resources
end

#resquestsObject

Returns the value of attribute resquests.



3
4
5
# File 'lib/doc_smoosher/api.rb', line 3

def resquests
  @resquests
end

#versionObject

Returns the value of attribute version.



3
4
5
# File 'lib/doc_smoosher/api.rb', line 3

def version
  @version
end

Instance Method Details

#as_json(options = {}) ⇒ Object



44
45
46
47
48
49
50
51
52
# File 'lib/doc_smoosher/api.rb', line 44

def as_json(options={})
  {
    :name => name,
    :description => description,
    :version => version,
    :format => format,
    :resources => self.resources.map(&:as_json)
  }
end

#object(params = {}, &block) ⇒ Object



28
29
30
31
32
33
34
35
36
37
# File 'lib/doc_smoosher/api.rb', line 28

def object( params = {}, &block )
  if params.class == ApiObject
    o = params
  else
    o = ApiObject.new( params, &block )
  end
  
  objects << o unless objects.include?(o)
  o
end

#request(params = {}, &block) ⇒ Object



17
18
19
# File 'lib/doc_smoosher/api.rb', line 17

def request( params = {}, &block )

end

#resource(params = {}, &block) ⇒ Object



21
22
23
24
25
# File 'lib/doc_smoosher/api.rb', line 21

def resource( params = {}, &block )
  r = Resource.new( params, &block )
  resources << r unless resources.include?(r)
  r
end