class Swagger::Object
Public Class Methods
attr_swagger(*attributes)
click to toggle source
# File lib/ruby-swagger/object.rb, line 5 def self.attr_swagger(*attributes) attr_accessor(*attributes) @@swagger_attribs[to_s] = *attributes end
Public Instance Methods
bulk_set(object)
click to toggle source
# 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_attributes()
click to toggle source
# File lib/ruby-swagger/object.rb, line 10 def swagger_attributes @@swagger_attribs[self.class.to_s] end
to_json(options = nil)
click to toggle source
# File lib/ruby-swagger/object.rb, line 14 def to_json(options = nil) to_swagger.to_json(options) end
to_swagger()
click to toggle source
# File lib/ruby-swagger/object.rb, line 22 def to_swagger as_swagger end
to_yaml()
click to toggle source
# File lib/ruby-swagger/object.rb, line 18 def to_yaml to_swagger.to_yaml end
Protected Instance Methods
as_swagger()
click to toggle source
# File lib/ruby-swagger/object.rb, line 36 def as_swagger swagger = {} return swagger unless swagger_attributes swagger_attributes.each do |property| obj = send(property) obj = swaggerify(obj) swagger[property.to_s] = obj unless obj.nil? end swagger end
swaggerify(object)
click to toggle source
# File lib/ruby-swagger/object.rb, line 51 def swaggerify(object) return nil if object.nil? return object.to_swagger if object.respond_to?(:to_swagger) if object.is_a?(Array) object.map! do |element| swaggerify(element) end end object end