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.
40 41 42 43 |
# File 'lib/ocean-dynamo/associations/collection_proxy.rb', line 40 def initialize(klass, association) @association = association super klass end |
Instance Method Details
#<<(*records) ⇒ Object Also known as: push, append
190 191 192 |
# File 'lib/ocean-dynamo/associations/collection_proxy.rb', line 190 def <<(*records) proxy_association.concat(records) && self end |
#==(other) ⇒ Object
179 180 181 |
# File 'lib/ocean-dynamo/associations/collection_proxy.rb', line 179 def ==(other) load_target == other end |
#any?(&block) ⇒ Boolean
164 165 166 |
# File 'lib/ocean-dynamo/associations/collection_proxy.rb', line 164 def any?(&block) @association.any?(&block) end |
#build(attributes = {}, &block) ⇒ Object Also known as: new
86 87 88 |
# File 'lib/ocean-dynamo/associations/collection_proxy.rb', line 86 def build(attributes = {}, &block) @association.build(attributes, &block) end |
#clear ⇒ Object
117 118 119 120 |
# File 'lib/ocean-dynamo/associations/collection_proxy.rb', line 117 def clear delete_all self end |
#concat(*records) ⇒ Object
102 103 104 |
# File 'lib/ocean-dynamo/associations/collection_proxy.rb', line 102 def concat(*records) @association.concat(*records) end |
#count(column_name = nil, options = {}) ⇒ Object
144 145 146 |
# File 'lib/ocean-dynamo/associations/collection_proxy.rb', line 144 def count(column_name = nil, = {}) @association.count(column_name, ) end |
#create(attributes = {}, &block) ⇒ Object
92 93 94 |
# File 'lib/ocean-dynamo/associations/collection_proxy.rb', line 92 def create(attributes = {}, &block) @association.create(attributes, &block) end |
#create!(attributes = {}, &block) ⇒ Object
97 98 99 |
# File 'lib/ocean-dynamo/associations/collection_proxy.rb', line 97 def create!(attributes = {}, &block) @association.create!(attributes, &block) end |
#delete(*records) ⇒ Object
128 129 130 |
# File 'lib/ocean-dynamo/associations/collection_proxy.rb', line 128 def delete(*records) @association.delete(*records) end |
#delete_all ⇒ Object
112 113 114 |
# File 'lib/ocean-dynamo/associations/collection_proxy.rb', line 112 def delete_all @association.delete_all end |
#destroy(*records) ⇒ Object
133 134 135 |
# File 'lib/ocean-dynamo/associations/collection_proxy.rb', line 133 def destroy(*records) @association.destroy(*records) end |
#destroy_all ⇒ Object
123 124 125 |
# File 'lib/ocean-dynamo/associations/collection_proxy.rb', line 123 def destroy_all @association.destroy_all end |
#distinct ⇒ Object Also known as: uniq
138 139 140 |
# File 'lib/ocean-dynamo/associations/collection_proxy.rb', line 138 def distinct @association.distinct end |
#empty? ⇒ Boolean
159 160 161 |
# File 'lib/ocean-dynamo/associations/collection_proxy.rb', line 159 def empty? @association.empty? end |
#find(*args, &block) ⇒ Object
71 72 73 |
# File 'lib/ocean-dynamo/associations/collection_proxy.rb', line 71 def find(*args, &block) @association.find(*args, &block) end |
#first(*args) ⇒ Object
76 77 78 |
# File 'lib/ocean-dynamo/associations/collection_proxy.rb', line 76 def first(*args) @association.first(*args) end |
#include?(record) ⇒ Boolean
174 175 176 |
# File 'lib/ocean-dynamo/associations/collection_proxy.rb', line 174 def include?(record) @association.include?(record) end |
#last(*args) ⇒ Object
81 82 83 |
# File 'lib/ocean-dynamo/associations/collection_proxy.rb', line 81 def last(*args) @association.last(*args) end |
#length ⇒ Object
154 155 156 |
# File 'lib/ocean-dynamo/associations/collection_proxy.rb', line 154 def length @association.length end |
#load_target ⇒ Object
56 57 58 |
# File 'lib/ocean-dynamo/associations/collection_proxy.rb', line 56 def load_target @association.load_target end |
#loaded? ⇒ Boolean
61 62 63 |
# File 'lib/ocean-dynamo/associations/collection_proxy.rb', line 61 def loaded? @association.loaded? end |
#many?(&block) ⇒ Boolean
169 170 171 |
# File 'lib/ocean-dynamo/associations/collection_proxy.rb', line 169 def many?(&block) @association.many?(&block) end |
#prepend(*args) ⇒ Object
197 198 199 |
# File 'lib/ocean-dynamo/associations/collection_proxy.rb', line 197 def prepend(*args) raise NoMethodError, "prepend on association is not defined. Please use << or append" end |
#proxy_association ⇒ Object
46 47 48 |
# File 'lib/ocean-dynamo/associations/collection_proxy.rb', line 46 def proxy_association @association end |
#reload ⇒ Object
202 203 204 205 |
# File 'lib/ocean-dynamo/associations/collection_proxy.rb', line 202 def reload proxy_association.reload self end |
#replace(other_array) ⇒ Object
107 108 109 |
# File 'lib/ocean-dynamo/associations/collection_proxy.rb', line 107 def replace(other_array) @association.replace(other_array) end |
#select(select = nil, &block) ⇒ Object
66 67 68 |
# File 'lib/ocean-dynamo/associations/collection_proxy.rb', line 66 def select(select = nil, &block) @association.select(select, &block) end |
#size ⇒ Object
149 150 151 |
# File 'lib/ocean-dynamo/associations/collection_proxy.rb', line 149 def size @association.size end |
#target ⇒ Object
51 52 53 |
# File 'lib/ocean-dynamo/associations/collection_proxy.rb', line 51 def target @association.target end |
#to_ary ⇒ Object Also known as: to_a
184 185 186 |
# File 'lib/ocean-dynamo/associations/collection_proxy.rb', line 184 def to_ary load_target.dup end |