Class: Pedanco::Diffr::Change
- Inherits:
-
Object
- Object
- Pedanco::Diffr::Change
- Defined in:
- lib/pedanco/diffr/change.rb
Overview
Instance Attribute Summary collapse
-
#current ⇒ Any
The current state of the change.
-
#name ⇒ String, Symbol
The name identifier for the change set.
-
#previous ⇒ Any
The previous state of the change.
Instance Method Summary collapse
-
#initialize(name, current = nil, previous = nil) ⇒ Change
constructor
Initializes the data when passed via new().
-
#to_a ⇒ Array
Converts the Change into an array, following the ActiveRecord changes syntax.
Constructor Details
#initialize(name, current = nil, previous = nil) ⇒ Change
Initializes the data when passed via new().
32 33 34 35 36 37 |
# File 'lib/pedanco/diffr/change.rb', line 32 def initialize(name, current = nil, previous = nil) fail 'Name is required for a Change.' if name.blank? @name = name @current = current @previous = previous end |
Instance Attribute Details
#current ⇒ Any
Returns the current state of the change.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/pedanco/diffr/change.rb', line 19 class Change attr_accessor :name, :current, :previous # # Initializes the data when passed via new(). # # @param name [String/Symbol] (required) The name of the data # @param current [Any] (optional) The current value for the # change, defaults to nil. # @param previous [Any] (optional) The previous value for the # change, defaults to nil. # # @raise [RuntimeError] if name is nil or '' def initialize(name, current = nil, previous = nil) fail 'Name is required for a Change.' if name.blank? @name = name @current = current @previous = previous end # # Converts the Change into an array, following the ActiveRecord # changes syntax. The first position is the previous value, the # second is the current value. # # @return [Array] The array version of the Change def to_a [@previous, @current] end end |
#name ⇒ String, Symbol
Returns the name identifier for the change set.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/pedanco/diffr/change.rb', line 19 class Change attr_accessor :name, :current, :previous # # Initializes the data when passed via new(). # # @param name [String/Symbol] (required) The name of the data # @param current [Any] (optional) The current value for the # change, defaults to nil. # @param previous [Any] (optional) The previous value for the # change, defaults to nil. # # @raise [RuntimeError] if name is nil or '' def initialize(name, current = nil, previous = nil) fail 'Name is required for a Change.' if name.blank? @name = name @current = current @previous = previous end # # Converts the Change into an array, following the ActiveRecord # changes syntax. The first position is the previous value, the # second is the current value. # # @return [Array] The array version of the Change def to_a [@previous, @current] end end |
#previous ⇒ Any
Returns the previous state of the change.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/pedanco/diffr/change.rb', line 19 class Change attr_accessor :name, :current, :previous # # Initializes the data when passed via new(). # # @param name [String/Symbol] (required) The name of the data # @param current [Any] (optional) The current value for the # change, defaults to nil. # @param previous [Any] (optional) The previous value for the # change, defaults to nil. # # @raise [RuntimeError] if name is nil or '' def initialize(name, current = nil, previous = nil) fail 'Name is required for a Change.' if name.blank? @name = name @current = current @previous = previous end # # Converts the Change into an array, following the ActiveRecord # changes syntax. The first position is the previous value, the # second is the current value. # # @return [Array] The array version of the Change def to_a [@previous, @current] end end |
Instance Method Details
#to_a ⇒ Array
Converts the Change into an array, following the ActiveRecord changes syntax. The first position is the previous value, the second is the current value.
45 46 47 |
# File 'lib/pedanco/diffr/change.rb', line 45 def to_a [@previous, @current] end |