Sha256: d624cdf808d8090a9cb15704cf0c0e3fbc77cef94d75b3c51d8b5956e1a2f4e2

Contents?: true

Size: 571 Bytes

Versions: 1

Compression:

Stored size: 571 Bytes

Contents

# Provide a two-step definition process.
#
# 1. Use a config object to gather definitions
# 2. Transfer definitions to an actual instance of an object
#
module GraphQL::DefinitionHelpers::DefinedByConfig
  def self.included(base)
    base.extend(ClassMethods)
  end

  module ClassMethods
    # Pass the block to this class's `DefinitionConfig`,
    # The return the result of {DefinitionConfig#to_instance}
    def define(&block)
      config = self.const_get(:DefinitionConfig).new
      block && config.instance_eval(&block)
      config.to_instance
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
graphql-0.5.0 lib/graph_ql/definition_helpers/defined_by_config.rb