Module: Ecoportal::API::Common::GraphQL::ClassHelpers::InstanceMethods

Defined in:
lib/ecoportal/api/common/graphql/class_helpers.rb

Instance Method Summary collapse

Instance Method Details

#becomes(klass) ⇒ Object



7
8
9
10
11
12
13
14
15
16
# File 'lib/ecoportal/api/common/graphql/class_helpers.rb', line 7

def becomes(klass)
  klass.new.tap do |becoming|
    instance_variables.each do |var|
      becoming.instance_variable_set(
        var,
        instance_variable_get(var)
      )
    end
  end
end

#becomes_parent_classObject



18
19
20
# File 'lib/ecoportal/api/common/graphql/class_helpers.rb', line 18

def becomes_parent_class
  becomes(self.class.superclass)
end