Method: Swagger::Docs::SwaggerModelDSL.call

Defined in:
lib/swagger/docs/dsl.rb

.call(model_name, caller, &block) ⇒ Object



75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/swagger/docs/dsl.rb', line 75

def self.call(model_name, caller, &block)
  # Create a new SwaggerModelDSL instance, and instance_eval the block to it
  instance = new
  instance.instance_eval(&block)
  instance.id = model_name
  # Now return all of the set instance variables as a Hash
  instance.instance_variables.inject({}) { |result_hash, instance_var_name|
    key = instance_var_name[1..-1].to_sym  # Strip prefixed @ sign.
    result_hash[key] = instance.instance_variable_get(instance_var_name)
    result_hash # Gotta have the block return the result_hash
  }
end