Class: GraphQL::Define::InstanceDefinable::AssignAttribute

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

Instance Method Summary collapse

Methods included from Ruby2Keywords

ruby2_keywords

Constructor Details

#initialize(attr_name) ⇒ AssignAttribute

Returns a new instance of AssignAttribute.



226
227
228
# File 'lib/graphql/define/instance_definable.rb', line 226

def initialize(attr_name)
  @attr_assign_method = :"#{attr_name}="
end

Instance Method Details

#call(defn, *value) ⇒ Object

Even though we’re just using the first value here, We have to add a splat here to use ruby2_keywords, so that it will accept a [{}] input from the caller.



233
234
235
# File 'lib/graphql/define/instance_definable.rb', line 233

def call(defn, *value)
  defn.public_send(@attr_assign_method, value.first)
end