Sha256: 50130902f4e4493a68315c8c461f8abec0b31684a44716bddacb4b5cb307c341

Contents?: true

Size: 1.06 KB

Versions: 28

Compression:

Stored size: 1.06 KB

Contents

module Ecoportal
  module API
    module Common
      module GraphQL
        module ClassHelpers
          module InstanceMethods
            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

            def becomes_parent_class
              becomes(self.class.superclass)
            end
          end

          module ClassMethods
            include Ecoportal::API::Common::Content::ClassHelpers

            def const?(value)
              begin
                const_get(value)
              rescue NameError => e
                return false
              end
              true
            end            
          end

          class << self
            def included(base)
              base.send(:include, InstanceMethods)
              base.extend(ClassMethods)
            end
          end
        end
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
ecoportal-api-graphql-0.2.1 lib/ecoportal/api/common/graphql/class_helpers.rb
ecoportal-api-graphql-0.1.11 lib/ecoportal/api/common/graphql/class_helpers.rb
ecoportal-api-graphql-0.1.10 lib/ecoportal/api/common/graphql/class_helpers.rb
ecoportal-api-graphql-0.1.9 lib/ecoportal/api/common/graphql/class_helpers.rb
ecoportal-api-graphql-0.1.8 lib/ecoportal/api/common/graphql/class_helpers.rb
ecoportal-api-graphql-0.1.7 lib/ecoportal/api/common/graphql/class_helpers.rb
ecoportal-api-graphql-0.1.6 lib/ecoportal/api/common/graphql/class_helpers.rb
ecoportal-api-graphql-0.1.5 lib/ecoportal/api/common/graphql/class_helpers.rb