Class: Friendly::Associations::Set
- Inherits:
-
Object
- Object
- Friendly::Associations::Set
- Defined in:
- lib/friendly/associations/set.rb
Instance Attribute Summary collapse
-
#association_klass ⇒ Object
readonly
Returns the value of attribute association_klass.
-
#associations ⇒ Object
readonly
Returns the value of attribute associations.
-
#klass ⇒ Object
readonly
Returns the value of attribute klass.
Instance Method Summary collapse
- #add(name, options = {}) ⇒ Object
- #get(name) ⇒ Object
- #get_scope(name, document) ⇒ Object
-
#initialize(klass, association_klass = Association) ⇒ Set
constructor
A new instance of Set.
Constructor Details
#initialize(klass, association_klass = Association) ⇒ Set
Returns a new instance of Set.
6 7 8 9 10 |
# File 'lib/friendly/associations/set.rb', line 6 def initialize(klass, association_klass = Association) @klass = klass @association_klass = association_klass @associations = {} end |
Instance Attribute Details
#association_klass ⇒ Object (readonly)
Returns the value of attribute association_klass.
4 5 6 |
# File 'lib/friendly/associations/set.rb', line 4 def association_klass @association_klass end |
#associations ⇒ Object (readonly)
Returns the value of attribute associations.
4 5 6 |
# File 'lib/friendly/associations/set.rb', line 4 def associations @associations end |
#klass ⇒ Object (readonly)
Returns the value of attribute klass.
4 5 6 |
# File 'lib/friendly/associations/set.rb', line 4 def klass @klass end |
Instance Method Details
#add(name, options = {}) ⇒ Object
12 13 14 15 |
# File 'lib/friendly/associations/set.rb', line 12 def add(name, = {}) associations[name] = association_klass.new(klass, name, ) add_association_accessor(name) end |
#get(name) ⇒ Object
21 22 23 |
# File 'lib/friendly/associations/set.rb', line 21 def get(name) associations[name] end |
#get_scope(name, document) ⇒ Object
17 18 19 |
# File 'lib/friendly/associations/set.rb', line 17 def get_scope(name, document) get(name).scope(document) end |