lib/sync/view_helpers.rb
def sync_new(options = {})
      partial_name = options.fetch(:partial)
      resource     = options.fetch(:resource)
      scope        = options[:scope]
      direction    = options.fetch :direction, 'append'
      refetch      = options.fetch(:refetch, false)

      if refetch
        creator = RefetchPartialCreator.new(partial_name, resource, scope, self)
      else
        creator = PartialCreator.new(partial_name, resource, scope, self)
      end
      "
        <script type='text/javascript' data-sync-id='#{creator.selector}'>
          Sync.onReady(function(){
            var creator = new Sync.PartialCreator({
              name:         '#{partial_name}',
              resourceName: '#{creator.resource.name}',
              channel:      '#{creator.channel}',
              selector:     '#{creator.selector}',
              direction:    '#{direction}',
              refetch:      #{refetch}
            });
            creator.subscribe();
          });
        </script>
      ".html_safe
    end
# Setup listener for new resource from sync_new channel, appending
# partial in place
#
# options - The Hash of options
#   partial - The String partial filename without leading underscore
#   resource - The ActiveModel resource
#   scope - The ActiveModel resource to scope the new channel publishes to.
#           Used for restricting new resource publishes to 'owner' models.
#           ie, current_user, project, group, etc. When excluded, listens 
#           for global resource creates.
# 
#   direction - The String/Symbol direction to insert rendered partials.
#               One of :append, :prepend. Defaults to :append
#
# Examples
#   <%= sync_new partial: 'todo', resource: Todo.new, scope: @project %>
#   <%= sync_new partial: 'todo', resource: Todo.new, scope: @project, direction: :prepend %>
#  
Setup listener for new resource from sync_new channel, appending
partial in place

The Hash of options
partial - The String partial filename without leading underscore
resource - The ActiveModel resource
scope - The ActiveModel resource to scope the new channel publishes to.
Used for restricting new resource publishes to 'owner' models.
ie, current_user, project, group, etc. When excluded, listens
for global resource creates.

The String/Symbol direction to insert rendered partials.
One of :append, :prepend. Defaults to :append


Setup listener for new resource from sync_new channel appending partial in place The Hash of options partial - The String partial filename without leading underscore resource - The ActiveModel resource scope - The ActiveModel resource to scope the new channel publishes to . Used for restricting new resource publishes to ' owner ' models . ie current_user project group etc . When excluded listens for global resource creates . The String / Symbol direction to insert rendered partials . One of : append : prepend . Defaults to : append
def sync_new(options = {})
      partial_name = options.fetch(:partial)
      resource     = options.fetch(:resource)
      scope        = options[:scope]
      direction    = options.fetch :direction, 'append'
      refetch      = options.fetch(:refetch, false)
      if refetch
        creator = RefetchPartialCreator.new(partial_name, resource, scope, self)
      else
        creator = PartialCreator.new(partial_name, resource, scope, self)
      end
      "
        <script type='text/javascript' data-sync-id='#{creator.selector}'>
          Sync.onReady(function(){
            var creator = new Sync.PartialCreator({
              name:         '#{partial_name}',
              resourceName: '#{creator.resource.name}',
              channel:      '#{creator.channel}',
              selector:     '#{creator.selector}',
              direction:    '#{direction}',
              refetch:      #{refetch}
            });
            creator.subscribe();
          });
        </script>
      ".html_safe
    end
def sync_new ( options = { } ) partial_name = options . fetch ( :partial ) resource = options . fetch ( :resource ) scope = options [ :scope ] direction = options . fetch :direction , 'append' refetch = options . fetch ( :refetch , false ) if refetch creator = RefetchPartialCreator . new ( partial_name , resource , scope , self ) else creator = PartialCreator . new ( partial_name , resource , scope , self ) end "
        <script type='text/javascript' data-sync-id='#{creator.selector}'>
          Sync.onReady(function(){
            var creator = new Sync.PartialCreator({
              name:         '#{partial_name}',
              resourceName: '#{creator.resource.name}',
              channel:      '#{creator.channel}',
              selector:     '#{creator.selector}',
              direction:    '#{direction}',
              refetch:      #{refetch}
            });
            creator.subscribe();
          });
        </script>
      " . html_safe end
Setup listener for new resource from sync_new channel, appending
partial in place
Setup listener for new resource from sync_new channel appending partial in place
options