Class: Oort::Removes
- Inherits:
-
Object
- Object
- Oort::Removes
- Defined in:
- lib/oort/removes.rb
Overview
Oort.configure do |config|
config.option = 'this'
end
Instance Attribute Summary collapse
-
#class_name ⇒ Object
readonly
Returns the value of attribute class_name.
-
#remove_from_method_name ⇒ Object
readonly
Returns the value of attribute remove_from_method_name.
-
#stored_in ⇒ Object
readonly
Returns the value of attribute stored_in.
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(stored_in:, remove_from_method_name:, class_name:) ⇒ Removes
constructor
A new instance of Removes.
Constructor Details
#initialize(stored_in:, remove_from_method_name:, class_name:) ⇒ Removes
Returns a new instance of Removes.
14 15 16 17 18 |
# File 'lib/oort/removes.rb', line 14 def initialize(stored_in:, remove_from_method_name:, class_name:) @stored_in = stored_in @remove_from_method_name = remove_from_method_name @class_name = class_name end |
Instance Attribute Details
#class_name ⇒ Object (readonly)
Returns the value of attribute class_name.
12 13 14 |
# File 'lib/oort/removes.rb', line 12 def class_name @class_name end |
#remove_from_method_name ⇒ Object (readonly)
Returns the value of attribute remove_from_method_name.
12 13 14 |
# File 'lib/oort/removes.rb', line 12 def remove_from_method_name @remove_from_method_name end |
#stored_in ⇒ Object (readonly)
Returns the value of attribute stored_in.
12 13 14 |
# File 'lib/oort/removes.rb', line 12 def stored_in @stored_in end |
Class Method Details
.call(stored_in:, remove_from_method_name:, class_name:) ⇒ Object
8 9 10 |
# File 'lib/oort/removes.rb', line 8 def self.call(stored_in:, remove_from_method_name:, class_name:) new(stored_in: stored_in, remove_from_method_name: remove_from_method_name, class_name: class_name).call end |
Instance Method Details
#call ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/oort/removes.rb', line 20 def call class_name.class_eval( # def remove_from_posts_ordering(id) # with_lock do # current_values = public_send(stored_in.inspect) # current_index = current_values.find_index(id) # current_values.delete_at(current_index) # update(stored_in.inspect => current_values) # end # end <<-RUBY, __FILE__, __LINE__ + 1 def #{remove_from_method_name}(id) with_lock do current_values = public_send(#{stored_in.inspect}) current_index = current_values.find_index(id) return if current_index.blank? current_values.delete_at(current_index) update(#{stored_in.inspect} => current_values) end end RUBY ) end |