class RenderSync::Action

Attributes

name[RW]
record[RW]
scope[RW]

Public Class Methods

new(record, name, *args) click to toggle source
# File lib/render_sync/action.rb, line 7
def initialize(record, name, *args)
  options = args.extract_options!
  @record = record
  @name = name
  @scope = get_scope_from_options(options)
end

Public Instance Methods

perform() click to toggle source
# File lib/render_sync/action.rb, line 14
def perform
  case name
  when :new
    sync_new record, scope: scope
  when :update
    sync_update record, scope: scope
  when :destroy
    sync_destroy record, scope: scope
  end
end
test_path() click to toggle source

Just for testing purposes (see test/sync/model_test.rb)

# File lib/render_sync/action.rb, line 26
def test_path
  Resource.new(record, scope).polymorphic_path.to_s
end

Private Instance Methods

get_scope_from_options(options) click to toggle source

Merge default_scope and scope from options Hash compact array to remove nil elements

# File lib/render_sync/action.rb, line 34
def get_scope_from_options(options)
  [options[:default_scope], options[:scope]].compact
end