Class: AttrJson::Associations::Association::Base
- Inherits:
-
Object
- Object
- AttrJson::Associations::Association::Base
- Defined in:
- lib/attr_json/associations/association/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#class_name ⇒ Object
Returns the value of attribute class_name.
-
#foreign_key ⇒ Object
Returns the value of attribute foreign_key.
-
#klass ⇒ Object
Returns the value of attribute klass.
-
#name ⇒ Object
Returns the value of attribute name.
-
#options ⇒ Object
Returns the value of attribute options.
-
#owner ⇒ Object
Returns the value of attribute owner.
-
#primary_key ⇒ Object
Returns the value of attribute primary_key.
-
#scope ⇒ Object
Returns the value of attribute scope.
Instance Method Summary collapse
-
#initialize(owner, args, options = {}) ⇒ Base
constructor
A new instance of Base.
- #scoped ⇒ Object
Constructor Details
#initialize(owner, args, options = {}) ⇒ Base
Returns a new instance of Base.
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/attr_json/associations/association/base.rb', line 9 def initialize(owner, args, = {}) @owner = owner @name = args[0] @scope = args[1] @options = @class_name = resolve(:class_name) @klass = @class_name.constantize @primary_key = resolve(:primary_key) @foreign_key = resolve(:foreign_key) end |
Instance Attribute Details
#class_name ⇒ Object
Returns the value of attribute class_name.
7 8 9 |
# File 'lib/attr_json/associations/association/base.rb', line 7 def class_name @class_name end |
#foreign_key ⇒ Object
Returns the value of attribute foreign_key.
7 8 9 |
# File 'lib/attr_json/associations/association/base.rb', line 7 def foreign_key @foreign_key end |
#klass ⇒ Object
Returns the value of attribute klass.
7 8 9 |
# File 'lib/attr_json/associations/association/base.rb', line 7 def klass @klass end |
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/attr_json/associations/association/base.rb', line 6 def name @name end |
#options ⇒ Object
Returns the value of attribute options.
6 7 8 |
# File 'lib/attr_json/associations/association/base.rb', line 6 def @options end |
#owner ⇒ Object
Returns the value of attribute owner.
6 7 8 |
# File 'lib/attr_json/associations/association/base.rb', line 6 def owner @owner end |
#primary_key ⇒ Object
Returns the value of attribute primary_key.
7 8 9 |
# File 'lib/attr_json/associations/association/base.rb', line 7 def primary_key @primary_key end |
#scope ⇒ Object
Returns the value of attribute scope.
6 7 8 |
# File 'lib/attr_json/associations/association/base.rb', line 6 def scope @scope end |
Instance Method Details
#scoped ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/attr_json/associations/association/base.rb', line 21 def scoped if @scope @klass.all.instance_exec(&@scope) else @klass.all end end |