Class: ViewModel::ActiveRecord::UpdateContext::ReleaseEntry

Inherits:
Struct
  • Object
show all
Defined in:
lib/view_model/active_record/update_context.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeReleaseEntry

Returns a new instance of ReleaseEntry.



9
10
11
12
# File 'lib/view_model/active_record/update_context.rb', line 9

def initialize(*)
  super
  @claimed = false
end

Instance Attribute Details

#association_dataObject

Returns the value of attribute association_data

Returns:

  • (Object)

    the current value of association_data



8
9
10
# File 'lib/view_model/active_record/update_context.rb', line 8

def association_data
  @association_data
end

#viewmodelObject

Returns the value of attribute viewmodel

Returns:

  • (Object)

    the current value of viewmodel



8
9
10
# File 'lib/view_model/active_record/update_context.rb', line 8

def viewmodel
  @viewmodel
end

Instance Method Details

#claimed!Object



24
25
26
# File 'lib/view_model/active_record/update_context.rb', line 24

def claimed!
  @claimed = true
end

#claimed?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/view_model/active_record/update_context.rb', line 28

def claimed?
  @claimed
end

#release!Object



14
15
16
17
18
19
20
21
22
# File 'lib/view_model/active_record/update_context.rb', line 14

def release!
  model = viewmodel.model
  case association_data.direct_reflection.options[:dependent]
  when :delete, :delete_all
    model.delete
  when :destroy, :destroy_async
    model.destroy
  end
end