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



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

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

Instance Method Details

#bulk_set(object) ⇒ Object



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

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

  self
end

#swagger_attributesObject



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

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

#to_json(options = nil) ⇒ Object



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

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

#to_swaggerObject



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

def to_swagger
  as_swagger
end

#to_yamlObject



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

def to_yaml
  to_swagger.to_yaml
end