Module: Jsapi::Meta::Model::Wrappable
- Included in:
- RequestBody, Schema::AdditionalProperties
- Defined in:
- lib/jsapi/meta/model/wrappable.rb
Overview
Defines a wrap class method to wrap an instance of the given class.
Class Method Summary collapse
-
.included(base) ⇒ Object
:nodoc:.
Class Method Details
.included(base) ⇒ Object
:nodoc:
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/jsapi/meta/model/wrappable.rb', line 8 def self.included(base) # :nodoc: class << base define_method(:wrap) do |model, definitions| return if model.nil? wrapper_class = "#{name}::Wrapper".constantize return model if model.is_a?(wrapper_class) wrapper_class.new(model, definitions) end end end |