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)
-
block
(Proc
) -- Block which calls helper methods from `accepts_definitions` -
kwargs
(Hash
) -- Key-value pairs corresponding to defininitions from `accepts_definitions`
def define(**kwargs, &block) instance = self.new instance.define(**kwargs, &block) 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 ensure_defined(*method_names)
def ensure_defined(*method_names) @ensure_defined_method_names ||= [] @ensure_defined_method_names.concat(method_names) nil end
def ensure_defined_method_names
def ensure_defined_method_names own_method_names = @ensure_defined_method_names || [] if superclass.respond_to?(:ensure_defined_method_names) superclass.ensure_defined_method_names + own_method_names else own_method_names end end
def own_dictionary
-
(Hash)
- definitions for this class only
def own_dictionary @own_dictionary ||= {} end