Class: Kanji::Type::MutationDefiner
- Inherits:
-
Object
- Object
- Kanji::Type::MutationDefiner
- Extended by:
- InstanceDefine
- Defined in:
- lib/kanji/type/mutation_definer.rb
Instance Method Summary collapse
- #argument(name, type, **kwargs) ⇒ Object
- #call ⇒ Object
-
#initialize(&block) ⇒ MutationDefiner
constructor
A new instance of MutationDefiner.
Methods included from InstanceDefine
Constructor Details
#initialize(&block) ⇒ MutationDefiner
Returns a new instance of MutationDefiner.
13 14 15 16 17 18 19 20 21 |
# File 'lib/kanji/type/mutation_definer.rb', line 13 def initialize(&block) @_arguments = [] self.instance_eval &block raise(AttributeError, "You must supply a name") unless @_name raise(AttributeError, "You must supply a return type") unless @_return_type raise(AttributeError, "You must supply a resolve proc") unless @_resolve raise(AttributeError, "You must supply at least one argument") if @_arguments.empty? end |
Instance Method Details
#argument(name, type, **kwargs) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/kanji/type/mutation_definer.rb', line 23 def argument(name, type, **kwargs) raise ArgumentError if @_arguments.map(&:name).include?(name.to_s) @_arguments << Argument.new({ name: name.to_s, type: type, options: kwargs }) end |