Module: GraphqlRails::InputConfigurable
- Included in:
- Attributes::Attribute, Controller::ActionConfiguration
- Defined in:
- lib/graphql_rails/input_configurable.rb
Overview
contains configuration options related with inputs
Instance Method Summary collapse
- #build_input_attribute(name, options: {}, **other_options) ⇒ Object
- #input_attribute_options ⇒ Object
- #paginated(pagination_options = {}) ⇒ Object
- #paginated? ⇒ Boolean
- #pagination_options ⇒ Object
- #permit(*args) ⇒ Object
- #permit_input(name, **input_options) ⇒ Object
Instance Method Details
#build_input_attribute(name, options: {}, **other_options) ⇒ Object
44 45 46 47 |
# File 'lib/graphql_rails/input_configurable.rb', line 44 def build_input_attribute(name, options: {}, **) = .merge() Attributes::InputAttribute.new(name.to_s, config: self).with(options: , **) end |
#input_attribute_options ⇒ Object
40 41 42 |
# File 'lib/graphql_rails/input_configurable.rb', line 40 def @input_attribute_options || {} end |
#paginated(pagination_options = {}) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/graphql_rails/input_configurable.rb', line 24 def paginated( = {}) = {} if == true = nil if == false @pagination_options = self end |
#paginated? ⇒ Boolean
32 33 34 |
# File 'lib/graphql_rails/input_configurable.rb', line 32 def paginated? !.nil? end |
#pagination_options ⇒ Object
36 37 38 |
# File 'lib/graphql_rails/input_configurable.rb', line 36 def @pagination_options end |
#permit(*args) ⇒ Object
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/graphql_rails/input_configurable.rb', line 6 def permit(*args) args.each do |arg| if arg.is_a? Hash arg.each { |attribute, type| permit_input(attribute, type: type) } else permit_input(arg) end end self end |
#permit_input(name, **input_options) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/graphql_rails/input_configurable.rb', line 17 def permit_input(name, **) field_name = name.to_s.remove(/!\Z/) attributes[field_name] = build_input_attribute(name.to_s, **) self end |