module GraphQL::Define::InstanceDefinable::ClassMethods
def accepts_definitions(*accepts)
Each symbol in `accepts` will be assigned with `{key}=`.
Attach definitions to this class.
def accepts_definitions(*accepts) new_assignments = if accepts.last.is_a?(Hash) accepts.pop.dup else {} end accepts.each do |key| new_assignments[key] = AssignAttribute.new(key) end @own_dictionary = own_dictionary.merge(new_assignments) end
def define(**kwargs, &block)
Note that the block is not called right away -- instead, it's deferred until
Prepare the defintion for an instance of this class using its {.definitions}.
def define(**kwargs, &block) instance = self.new instance.definition_proc = -> (obj) { kwargs.each do |keyword, value| public_send(keyword, value) end if block instance_eval(&block) end } instance end
def dictionary
-
(Hash)
- combined definitions for self and ancestors
def dictionary if superclass.respond_to?(:dictionary) own_dictionary.merge(superclass.dictionary) else own_dictionary end end
def lazy_defined_attr_accessor(*attr_names)
Define a reader and writer for each of `attr_names` which
def lazy_defined_attr_accessor(*attr_names) attr_names.each do |attr_name| ivar_name = :"@#{attr_name}" define_method(attr_name) do ensure_defined instance_variable_get(ivar_name) end define_method("#{attr_name}=") do |new_value| ensure_defined instance_variable_set(ivar_name, new_value) end end end
def own_dictionary
-
(Hash)
- definitions for this class only
def own_dictionary @own_dictionary ||= {} end