Class: Swagger::Object

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby-swagger/object.rb

Constant Summary collapse

@@swagger_attribs =
{}

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.attr_swagger(*attributes) ⇒ Object



5
6
7
8
# File 'lib/ruby-swagger/object.rb', line 5

def self.attr_swagger(*attributes)
  attr_accessor(*attributes)
  @@swagger_attribs[to_s] = *attributes
end

Instance Method Details

#bulk_set(object) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/ruby-swagger/object.rb', line 26

def bulk_set(object)
  swagger_attributes.each do |attribute|
    send("#{attribute}=", object[attribute.to_s])
  end

  self
end

#swagger_attributesObject



10
11
12
# File 'lib/ruby-swagger/object.rb', line 10

def swagger_attributes
  @@swagger_attribs[self.class.to_s]
end

#to_json(options = nil) ⇒ Object



14
15
16
# File 'lib/ruby-swagger/object.rb', line 14

def to_json(options = nil)
  to_swagger.to_json(options)
end

#to_swaggerObject



22
23
24
# File 'lib/ruby-swagger/object.rb', line 22

def to_swagger
  as_swagger
end

#to_yamlObject



18
19
20
# File 'lib/ruby-swagger/object.rb', line 18

def to_yaml
  to_swagger.to_yaml
end