Class: OceanDynamo::Associations::CollectionProxy
- Defined in:
- lib/ocean-dynamo/associations/collection_proxy.rb
Instance Attribute Summary
Attributes inherited from Relation
Instance Method Summary collapse
- #<<(*records) ⇒ Object (also: #push, #append)
- #==(other) ⇒ Object
- #any?(&block) ⇒ Boolean
- #build(attributes = {}, &block) ⇒ Object (also: #new)
- #clear ⇒ Object
- #concat(*records) ⇒ Object
- #count(column_name = nil, options = {}) ⇒ Object
- #create(attributes = {}, &block) ⇒ Object
- #create!(attributes = {}, &block) ⇒ Object
- #delete(*records) ⇒ Object
- #delete_all ⇒ Object
- #destroy(*records) ⇒ Object
- #destroy_all ⇒ Object
- #distinct ⇒ Object (also: #uniq)
- #empty? ⇒ Boolean
- #find(*args, &block) ⇒ Object
- #first(*args) ⇒ Object
- #include?(record) ⇒ Boolean
-
#initialize(klass, association) ⇒ CollectionProxy
constructor
A new instance of CollectionProxy.
- #last(*args) ⇒ Object
- #length ⇒ Object
- #load_target ⇒ Object
- #loaded? ⇒ Boolean
- #many?(&block) ⇒ Boolean
- #prepend(*args) ⇒ Object
- #proxy_association ⇒ Object
- #reload ⇒ Object
- #replace(other_array) ⇒ Object
- #select(select = nil, &block) ⇒ Object
- #size ⇒ Object
- #target ⇒ Object
- #to_ary ⇒ Object (also: #to_a)
Constructor Details
#initialize(klass, association) ⇒ CollectionProxy
Returns a new instance of CollectionProxy.
41 42 43 44 |
# File 'lib/ocean-dynamo/associations/collection_proxy.rb', line 41 def initialize(klass, association) @association = association super klass end |
Instance Method Details
#<<(*records) ⇒ Object Also known as: push, append
191 192 193 |
# File 'lib/ocean-dynamo/associations/collection_proxy.rb', line 191 def <<(*records) proxy_association.concat(records) && self end |
#==(other) ⇒ Object
180 181 182 |
# File 'lib/ocean-dynamo/associations/collection_proxy.rb', line 180 def ==(other) load_target == other end |
#any?(&block) ⇒ Boolean
165 166 167 |
# File 'lib/ocean-dynamo/associations/collection_proxy.rb', line 165 def any?(&block) @association.any?(&block) end |
#build(attributes = {}, &block) ⇒ Object Also known as: new
87 88 89 |
# File 'lib/ocean-dynamo/associations/collection_proxy.rb', line 87 def build(attributes = {}, &block) @association.build(attributes, &block) end |
#clear ⇒ Object
118 119 120 121 |
# File 'lib/ocean-dynamo/associations/collection_proxy.rb', line 118 def clear delete_all self end |
#concat(*records) ⇒ Object
103 104 105 |
# File 'lib/ocean-dynamo/associations/collection_proxy.rb', line 103 def concat(*records) @association.concat(*records) end |
#count(column_name = nil, options = {}) ⇒ Object
145 146 147 |
# File 'lib/ocean-dynamo/associations/collection_proxy.rb', line 145 def count(column_name = nil, = {}) @association.count(column_name, ) end |
#create(attributes = {}, &block) ⇒ Object
93 94 95 |
# File 'lib/ocean-dynamo/associations/collection_proxy.rb', line 93 def create(attributes = {}, &block) @association.create(attributes, &block) end |
#create!(attributes = {}, &block) ⇒ Object
98 99 100 |
# File 'lib/ocean-dynamo/associations/collection_proxy.rb', line 98 def create!(attributes = {}, &block) @association.create!(attributes, &block) end |
#delete(*records) ⇒ Object
129 130 131 |
# File 'lib/ocean-dynamo/associations/collection_proxy.rb', line 129 def delete(*records) @association.delete(*records) end |
#delete_all ⇒ Object
113 114 115 |
# File 'lib/ocean-dynamo/associations/collection_proxy.rb', line 113 def delete_all @association.delete_all end |
#destroy(*records) ⇒ Object
134 135 136 |
# File 'lib/ocean-dynamo/associations/collection_proxy.rb', line 134 def destroy(*records) @association.destroy(*records) end |
#destroy_all ⇒ Object
124 125 126 |
# File 'lib/ocean-dynamo/associations/collection_proxy.rb', line 124 def destroy_all @association.destroy_all end |
#distinct ⇒ Object Also known as: uniq
139 140 141 |
# File 'lib/ocean-dynamo/associations/collection_proxy.rb', line 139 def distinct @association.distinct end |
#empty? ⇒ Boolean
160 161 162 |
# File 'lib/ocean-dynamo/associations/collection_proxy.rb', line 160 def empty? @association.empty? end |
#find(*args, &block) ⇒ Object
72 73 74 |
# File 'lib/ocean-dynamo/associations/collection_proxy.rb', line 72 def find(*args, &block) @association.find(*args, &block) end |
#first(*args) ⇒ Object
77 78 79 |
# File 'lib/ocean-dynamo/associations/collection_proxy.rb', line 77 def first(*args) @association.first(*args) end |
#include?(record) ⇒ Boolean
175 176 177 |
# File 'lib/ocean-dynamo/associations/collection_proxy.rb', line 175 def include?(record) @association.include?(record) end |
#last(*args) ⇒ Object
82 83 84 |
# File 'lib/ocean-dynamo/associations/collection_proxy.rb', line 82 def last(*args) @association.last(*args) end |
#length ⇒ Object
155 156 157 |
# File 'lib/ocean-dynamo/associations/collection_proxy.rb', line 155 def length @association.length end |
#load_target ⇒ Object
57 58 59 |
# File 'lib/ocean-dynamo/associations/collection_proxy.rb', line 57 def load_target @association.load_target end |
#loaded? ⇒ Boolean
62 63 64 |
# File 'lib/ocean-dynamo/associations/collection_proxy.rb', line 62 def loaded? @association.loaded? end |
#many?(&block) ⇒ Boolean
170 171 172 |
# File 'lib/ocean-dynamo/associations/collection_proxy.rb', line 170 def many?(&block) @association.many?(&block) end |
#prepend(*args) ⇒ Object
198 199 200 |
# File 'lib/ocean-dynamo/associations/collection_proxy.rb', line 198 def prepend(*args) raise NoMethodError, "prepend on association is not defined. Please use << or append" end |
#proxy_association ⇒ Object
47 48 49 |
# File 'lib/ocean-dynamo/associations/collection_proxy.rb', line 47 def proxy_association @association end |
#reload ⇒ Object
203 204 205 206 |
# File 'lib/ocean-dynamo/associations/collection_proxy.rb', line 203 def reload proxy_association.reload self end |
#replace(other_array) ⇒ Object
108 109 110 |
# File 'lib/ocean-dynamo/associations/collection_proxy.rb', line 108 def replace(other_array) @association.replace(other_array) end |
#select(select = nil, &block) ⇒ Object
67 68 69 |
# File 'lib/ocean-dynamo/associations/collection_proxy.rb', line 67 def select(select = nil, &block) @association.select(select, &block) end |
#size ⇒ Object
150 151 152 |
# File 'lib/ocean-dynamo/associations/collection_proxy.rb', line 150 def size @association.size end |
#target ⇒ Object
52 53 54 |
# File 'lib/ocean-dynamo/associations/collection_proxy.rb', line 52 def target @association.target end |
#to_ary ⇒ Object Also known as: to_a
185 186 187 |
# File 'lib/ocean-dynamo/associations/collection_proxy.rb', line 185 def to_ary load_target.dup end |