Class: Bowline::Binders::Collection
- Inherits:
-
Base
show all
- Defined in:
- lib/bowline/binders/collection.rb
Defined Under Namespace
Classes: ItemsProxy
Instance Attribute Summary
Attributes inherited from Base
#element, #item
Class Method Summary
collapse
Methods inherited from Base
#dom, elements, format_event, inherited, #initialize, instance, jquery, #jquery, #js, js, loading, #logger, logger, observer, #observer, params, params=, setup, show_view, #show_view, trigger, #trigger
Class Method Details
51
52
53
54
55
|
# File 'lib/bowline/binders/collection.rb', line 51
def find(id)
@items.real.find {|item|
item.__id__ == id
}
end
|
.item_sync! ⇒ Object
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/bowline/binders/collection.rb', line 39
def item_sync!
return unless @items && @elements
value = @items.real.map {|item|
hash = item.to_js
hash.merge!({:_id => item.__id__})
hash.stringify_keys
}
@elements.each {|i|
i.updateCollection(value)
}
end
|
33
34
35
36
37
|
# File 'lib/bowline/binders/collection.rb', line 33
def items
@items ||= ItemsProxy.new {
self.item_sync!
}
end
|
.items=(args) ⇒ Object
25
26
27
28
29
30
31
|
# File 'lib/bowline/binders/collection.rb', line 25
def items=(args)
if args
items.replace(args)
else
items.clear
end
end
|