Class: RenderSync::Action

Inherits:
Object
  • Object
show all
Includes:
Actions
Defined in:
lib/render_sync/action.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Actions

#sync, #sync_destroy, #sync_new, #sync_update

Constructor Details

#initialize(record, name, *args) ⇒ Action

Returns a new instance of Action.



7
8
9
10
11
12
# 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

Instance Attribute Details

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/render_sync/action.rb', line 5

def name
  @name
end

#recordObject

Returns the value of attribute record.



5
6
7
# File 'lib/render_sync/action.rb', line 5

def record
  @record
end

#scopeObject

Returns the value of attribute scope.



5
6
7
# File 'lib/render_sync/action.rb', line 5

def scope
  @scope
end

Instance Method Details

#performObject



14
15
16
17
18
19
20
21
22
23
# 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_pathObject

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



26
27
28
# File 'lib/render_sync/action.rb', line 26

def test_path
  Resource.new(record, scope).polymorphic_path.to_s
end