Class: Bowline::Binders::Singleton

Inherits:
Base show all
Defined in:
lib/bowline/binders/singleton.rb

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

Constructor Details

This class inherits a constructor from Bowline::Binders::Base

Class Method Details

.find(*a) ⇒ Object



25
26
27
# File 'lib/bowline/binders/singleton.rb', line 25

def find(*a)
  @item
end

.itemObject



5
6
7
# File 'lib/bowline/binders/singleton.rb', line 5

def item
  @item
end

.item=(arg) ⇒ Object



9
10
11
12
# File 'lib/bowline/binders/singleton.rb', line 9

def item=(arg)
  @item = arg
  self.item_sync!
end

.item_sync!Object



14
15
16
17
18
19
20
21
22
23
# File 'lib/bowline/binders/singleton.rb', line 14

def item_sync!
  return unless @item && @elements
  value = @item.to_js
  value.merge!({:_id => @item.__id__})
  value.stringify_keys!
  # Call the chain.js function 'item' on elements
  @elements.each {|i| 
    i.updateSingleton(value) 
  }
end