Class: Sequencescape::Api::Associations::HasMany::AssociationProxy
Instance Method Summary
collapse
extended
Methods included from Validation
#errors, #run_validations!
Methods included from Json
#as_json, included
#all
#all, extended, #find, included
included, #proxy_present?
Constructor Details
#initialize(owner, json = nil) ⇒ AssociationProxy
Returns a new instance of AssociationProxy.
33
34
35
36
37
38
|
# File 'lib/sequencescape-api/associations/has_many.rb', line 33
def initialize(owner, json = nil)
super
@cached_all = case json
when Array then json.map { |js| new_from(js) }
end
end
|
Instance Method Details
#empty? ⇒ Boolean
23
24
25
26
27
|
# File 'lib/sequencescape-api/associations/has_many.rb', line 23
def empty?
return @_attributes_['size'].zero? if api.capabilities.size_in_pages?
all.empty?
end
|
#new_from(json) ⇒ Object
40
41
42
43
44
45
46
|
# File 'lib/sequencescape-api/associations/has_many.rb', line 40
def new_from(json)
case json
when String then new(uuid: json) when Hash then new(json)
else json
end
end
|
#present? ⇒ Boolean
29
30
31
|
# File 'lib/sequencescape-api/associations/has_many.rb', line 29
def present?
!empty?
end
|
#size ⇒ Object
17
18
19
20
21
|
# File 'lib/sequencescape-api/associations/has_many.rb', line 17
def size
return @_attributes_['size'] if api.capabilities.size_in_pages?
all.size
end
|
#update_from_json(_) ⇒ Object
48
49
50
|
# File 'lib/sequencescape-api/associations/has_many.rb', line 48
def update_from_json(_)
@cached_all = nil
end
|