Module: GraphQL::Define::InstanceDefinable::ClassMethods
- Defined in:
- lib/graphql/define/instance_definable.rb
Instance Method Summary collapse
-
#accepts_definitions(*accepts) ⇒ Object
Attach definitions to this class.
-
#define(&block) ⇒ Object
Define an instance of this class using its definitions.
-
#dictionary ⇒ Hash
Combined definitions for self and ancestors.
-
#own_dictionary ⇒ Hash
Definitions for this class only.
Instance Method Details
#accepts_definitions(*accepts) ⇒ Object
Attach definitions to this class. Each symbol in ‘accepts` will be assigned with `key=`. The last entry in accepts may be a hash of name-proc pairs for custom definitions.
59 60 61 |
# File 'lib/graphql/define/instance_definable.rb', line 59 def accepts_definitions(*accepts) @own_dictionary = own_dictionary.merge(AssignmentDictionary.create(*accepts)) end |
#define(&block) ⇒ Object
Define an instance of this class using its definitions.
49 50 51 52 53 54 |
# File 'lib/graphql/define/instance_definable.rb', line 49 def define(&block) instance = self.new proxy = DefinedObjectProxy.new(instance, dictionary) block && proxy.instance_eval(&block) instance end |
#dictionary ⇒ Hash
Returns combined definitions for self and ancestors.
64 65 66 67 68 69 70 |
# File 'lib/graphql/define/instance_definable.rb', line 64 def dictionary if superclass.respond_to?(:dictionary) own_dictionary.merge(superclass.dictionary) else own_dictionary end end |
#own_dictionary ⇒ Hash
Returns definitions for this class only.
73 74 75 |
# File 'lib/graphql/define/instance_definable.rb', line 73 def own_dictionary @own_dictionary ||= {} end |