Class: GraphQL::Configuration::Slot
- Inherits:
- 
      Object
      
        - Object
- GraphQL::Configuration::Slot
 
- Defined in:
- lib/graphql/configuration/slot.rb
Instance Method Summary collapse
- #effective_type ⇒ Object
- #errors ⇒ Object
- 
  
    
      #initialize(*args, &block)  ⇒ Slot 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    A new instance of Slot. 
- #list? ⇒ Boolean
- #valid? ⇒ Boolean
- #validate ⇒ Object
Constructor Details
#initialize(*args, &block) ⇒ Slot
Returns a new instance of Slot.
| 6 7 8 9 10 11 12 13 14 | # File 'lib/graphql/configuration/slot.rb', line 6 def initialize(*args, &block) define_methods = args.last.is_a?(Hash) ? args.pop : {} .keys.each { |key| [key.to_sym] = .delete(key) } attributes.each { |name| [name.to_sym] = args.shift if args.size > 0 } .each { |key, value| public_send(key, value) } instance_eval(&block) if block_given? validate! end | 
Instance Method Details
#effective_type ⇒ Object
| 20 21 22 23 24 25 26 | # File 'lib/graphql/configuration/slot.rb', line 20 def effective_type @effective_type ||= begin t = list? ? type.first : type t = t.call if t.is_a?(Proc) t end end | 
#errors ⇒ Object
| 28 29 30 | # File 'lib/graphql/configuration/slot.rb', line 28 def errors @errors ||= {} end | 
#list? ⇒ Boolean
| 16 17 18 | # File 'lib/graphql/configuration/slot.rb', line 16 def list? type.is_a?(Array) end | 
#valid? ⇒ Boolean
| 32 33 34 | # File 'lib/graphql/configuration/slot.rb', line 32 def valid? errors.size == 0 end | 
#validate ⇒ Object
| 36 37 38 39 | # File 'lib/graphql/configuration/slot.rb', line 36 def validate @errors = {} attributes.each { |name| send(:"validate_#{name}") } end |