Class: GraphQL::Client::Schema::EnumType::EnumValue
- Inherits:
-
String
- Object
- String
- GraphQL::Client::Schema::EnumType::EnumValue
- Defined in:
- lib/graphql/client/schema/enum_type.rb
Instance Method Summary collapse
-
#initialize(obj, enum_value, enum) ⇒ EnumValue
constructor
A new instance of EnumValue.
- #method_missing(method_name, *args) ⇒ Object
- #respond_to_missing?(method_name, include_private = false) ⇒ Boolean
Constructor Details
#initialize(obj, enum_value, enum) ⇒ EnumValue
Returns a new instance of EnumValue.
13 14 15 16 17 |
# File 'lib/graphql/client/schema/enum_type.rb', line 13 def initialize(obj, enum_value, enum) super(obj) @enum_value = enum_value @enum = enum end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/graphql/client/schema/enum_type.rb', line 27 def method_missing(method_name, *args) if method_name[-1] == "?" queried_value = method_name[0..-2] if @enum.include?(queried_value) raise ArgumentError, "wrong number of arguments (given #{args.size}, expected 0)" unless args.empty? return @enum_value == queried_value end end super end |
Instance Method Details
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
19 20 21 22 23 24 25 |
# File 'lib/graphql/client/schema/enum_type.rb', line 19 def respond_to_missing?(method_name, include_private = false) if method_name[-1] == "?" && @enum.include?(method_name[0..-2]) true else super end end |