Sha256: 534fdd31f3c37b17cd8d16655c1b45762c75c7e66cf6b474820f07fabc005fac

Contents?: true

Size: 630 Bytes

Versions: 8

Compression:

Stored size: 630 Bytes

Contents

module Bowline
  module Binders
    class Singleton < Base
      class << self
        def item
          @item
        end
        
        def item=(arg)
          @item = arg
          self.item_sync!
        end
    
        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
      
        def find(*a)
          @item
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
maccman-bowline-0.4.1 lib/bowline/binders/singleton.rb
maccman-bowline-0.4.3 lib/bowline/binders/singleton.rb
maccman-bowline-0.4.4 lib/bowline/binders/singleton.rb
maccman-bowline-0.4.5 lib/bowline/binders/singleton.rb
maccman-bowline-0.4.6 lib/bowline/binders/singleton.rb
maccman-bowline-0.4.7 lib/bowline/binders/singleton.rb
maccman-bowline-0.4.8 lib/bowline/binders/singleton.rb
bowline-0.4.6 lib/bowline/binders/singleton.rb