Module: Grape::Entity::Delegator

Defined in:
lib/grape_entity/delegator.rb,
lib/grape_entity/delegator/base.rb,
lib/grape_entity/delegator/hash_object.rb,
lib/grape_entity/delegator/plain_object.rb,
lib/grape_entity/delegator/openstruct_object.rb

Defined Under Namespace

Classes: Base, HashObject, OpenStructObject, PlainObject

Class Method Summary collapse

Class Method Details

.new(object) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/grape_entity/delegator.rb', line 11

def self.new(object)
  delegator_klass =
    if object.is_a?(Hash)
      HashObject
    elsif defined?(OpenStruct) && object.is_a?(OpenStruct)
      OpenStructObject
    else
      PlainObject
    end

  delegator_klass.new(object)
end