Class: GraphQL::Define::InstanceDefinable::Definition

Inherits:
Object
  • Object
show all
Defined in:
lib/graphql/define/instance_definable.rb

Instance Method Summary collapse

Constructor Details

#initialize(define_keywords, define_proc) ⇒ Definition

Returns a new instance of Definition


131
132
133
134
# File 'lib/graphql/define/instance_definable.rb', line 131

def initialize(define_keywords, define_proc)
  @define_keywords = define_keywords
  @define_proc = define_proc
end

Instance Method Details

#apply(instance) ⇒ Object


136
137
138
139
140
141
142
143
144
145
146
# File 'lib/graphql/define/instance_definable.rb', line 136

def apply(instance)
  defn_proxy = DefinedObjectProxy.new(instance)

  @define_keywords.each do |keyword, value|
    defn_proxy.public_send(keyword, value)
  end

  if @define_proc
    defn_proxy.instance_eval(&@define_proc)
  end
end