Class: GraphQL::Rails::ActiveReflection::ModelReflection
- Inherits:
-
Object
- Object
- GraphQL::Rails::ActiveReflection::ModelReflection
- Defined in:
- lib/graphql/rails/active_reflection/model_reflection.rb
Class Attribute Summary collapse
-
.schema_name ⇒ Object
Returns the value of attribute schema_name.
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(klass, schema) ⇒ ModelReflection
constructor
A new instance of ModelReflection.
Constructor Details
#initialize(klass, schema) ⇒ ModelReflection
Returns a new instance of ModelReflection.
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/graphql/rails/active_reflection/model_reflection.rb', line 14 def initialize(klass, schema) @klass = klass @type = schema.resolve_type(@klass) @schema = schema @attributes = @type.fields.map { |field| # No reflection if it's not a model attribute property = field.property || field.name return nil unless klass.attribute_names.include? property AttributeReflection.new(field, klass, schema) }.compact end |
Class Attribute Details
.schema_name ⇒ Object
Returns the value of attribute schema_name.
28 29 30 |
# File 'lib/graphql/rails/active_reflection/model_reflection.rb', line 28 def schema_name @schema_name end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
12 13 14 |
# File 'lib/graphql/rails/active_reflection/model_reflection.rb', line 12 def attributes @attributes end |
Class Method Details
.call(obj, args, ctx) ⇒ Object
7 8 9 10 |
# File 'lib/graphql/rails/active_reflection/model_reflection.rb', line 7 def self.call(obj, args, ctx) raise UnsupportedObject unless obj < ActiveRecord::Base @reflections[obj.class] ||= new(obj.class, ctx.schema) end |