class MutationGenerator::GeneratedAttribute
Constants
- FILTER_OPTIONS
- INPUT_OPTIONS
Attributes
filter[RW]
input_type[RW]
name[RW]
Public Class Methods
new(name, filter, input_type)
click to toggle source
# File lib/generators/mutation/mutation_generator.rb, line 74 def initialize(name, filter, input_type) @name = name @filter = filter || 'string' @input_type = input_type || 'required' end
parse(definition)
click to toggle source
# File lib/generators/mutation/mutation_generator.rb, line 43 def parse(definition) name, filter, input_type = definition.split(':') raise 'name required' if name.nil? raise 'filter type required' if filter.nil? input_type ||= 'required' filter = validate_filter!(filter) input_type = validate_input_type!(input_type) name = name.to_sym new(name, filter, input_type) end
validate_filter!(filter)
click to toggle source
# File lib/generators/mutation/mutation_generator.rb, line 65 def validate_filter!(filter) unless FILTER_OPTIONS.include?(filter) raise "invalid filter type must be one of #{FILTER_OPTIONS}" end filter end
validate_input_type!(input_type)
click to toggle source
# File lib/generators/mutation/mutation_generator.rb, line 57 def validate_input_type!(input_type) unless INPUT_OPTIONS.include?(input_type) raise "invalid input type must be one of #{INPUT_OPTIONS}" end input_type end