Class: RubySync::Operation
Overview
Operations that may be performed on an attribute
Instance Attribute Summary collapse
-
#subject ⇒ Object
Returns the value of attribute subject.
-
#type ⇒ Object
Returns the value of attribute type.
-
#values ⇒ Object
Returns the value of attribute values.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(type, subject, values) ⇒ Operation
constructor
A new instance of Operation.
-
#same_but_as(type) ⇒ Object
Returns a duplicate of this operation but with the type changed to the specified type.
-
#same_but_on(subject) ⇒ Object
Returns a duplicate of this operation but with the subject changed to the specified subject.
-
#same_but_with(values) ⇒ Object
Returns a duplicate of this operation but with the values changed to those specified.
Constructor Details
#initialize(type, subject, values) ⇒ Operation
Returns a new instance of Operation.
37 38 39 40 41 |
# File 'lib/ruby_sync/operation.rb', line 37 def initialize type, subject, values self.type = type.to_sym self.subject = subject.to_s self.values = values end |
Instance Attribute Details
#subject ⇒ Object
Returns the value of attribute subject.
21 22 23 |
# File 'lib/ruby_sync/operation.rb', line 21 def subject @subject end |
#type ⇒ Object
Returns the value of attribute type.
21 22 23 |
# File 'lib/ruby_sync/operation.rb', line 21 def type @type end |
#values ⇒ Object
Returns the value of attribute values.
21 22 23 |
# File 'lib/ruby_sync/operation.rb', line 21 def values @values end |
Class Method Details
.add(subject, values) ⇒ Object
24 25 26 |
# File 'lib/ruby_sync/operation.rb', line 24 def self.add subject, values self.new(:add, subject, values) end |
.delete(subject, values) ⇒ Object
28 29 30 |
# File 'lib/ruby_sync/operation.rb', line 28 def self.delete subject, values self.new(:delete, subject, values) end |
.replace(subject, values) ⇒ Object
32 33 34 |
# File 'lib/ruby_sync/operation.rb', line 32 def self.replace subject, values self.new(:replace, subject, values) end |
Instance Method Details
#same_but_as(type) ⇒ Object
Returns a duplicate of this operation but with the type changed to the specified type
66 67 68 69 70 |
# File 'lib/ruby_sync/operation.rb', line 66 def same_but_as type op = self.dup op.type = type op end |
#same_but_on(subject) ⇒ Object
Returns a duplicate of this operation but with the subject changed to the specified subject
58 59 60 61 62 |
# File 'lib/ruby_sync/operation.rb', line 58 def same_but_on subject op = self.dup op.subject = subject op end |
#same_but_with(values) ⇒ Object
Returns a duplicate of this operation but with the values changed to those specified
74 75 76 77 78 |
# File 'lib/ruby_sync/operation.rb', line 74 def same_but_with values op = self.dub op.values = values op end |