Class: HQ::GraphQL::ObjectAssociation::ResourceReflection
- Inherits:
-
Object
- Object
- HQ::GraphQL::ObjectAssociation::ResourceReflection
- Defined in:
- lib/hq/graphql/object_association.rb
Instance Attribute Summary collapse
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#macro ⇒ Object
readonly
Returns the value of attribute macro.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#scope ⇒ Object
readonly
Returns the value of attribute scope.
Instance Method Summary collapse
-
#initialize(name, scope, options, macro, block) ⇒ ResourceReflection
constructor
A new instance of ResourceReflection.
- #reflection(model_klass) ⇒ Object
Constructor Details
#initialize(name, scope, options, macro, block) ⇒ ResourceReflection
Returns a new instance of ResourceReflection.
41 42 43 44 45 46 47 |
# File 'lib/hq/graphql/object_association.rb', line 41 def initialize(name, scope, , macro, block) @name = name @scope = scope @options = @macro = macro @block = block end |
Instance Attribute Details
#block ⇒ Object (readonly)
Returns the value of attribute block.
39 40 41 |
# File 'lib/hq/graphql/object_association.rb', line 39 def block @block end |
#macro ⇒ Object (readonly)
Returns the value of attribute macro.
39 40 41 |
# File 'lib/hq/graphql/object_association.rb', line 39 def macro @macro end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
39 40 41 |
# File 'lib/hq/graphql/object_association.rb', line 39 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
39 40 41 |
# File 'lib/hq/graphql/object_association.rb', line 39 def @options end |
#scope ⇒ Object (readonly)
Returns the value of attribute scope.
39 40 41 |
# File 'lib/hq/graphql/object_association.rb', line 39 def scope @scope end |
Instance Method Details
#reflection(model_klass) ⇒ Object
49 50 51 52 53 54 55 |
# File 'lib/hq/graphql/object_association.rb', line 49 def reflection(model_klass) if macro == :has_many ::ActiveRecord::Associations::Builder::HasMany.create_reflection(model_klass, name, scope, ) elsif macro == :belongs_to ::ActiveRecord::Associations::Builder::BelongsTo.create_reflection(model_klass, name, scope, ) end end |