Class: Watchly::Changeset
- Inherits:
-
Object
- Object
- Watchly::Changeset
- Defined in:
- lib/watchly/changeset.rb
Instance Attribute Summary collapse
-
#added ⇒ Object
readonly
Returns the value of attribute added.
-
#files ⇒ Object
readonly
Returns the value of attribute files.
-
#modified ⇒ Object
readonly
Returns the value of attribute modified.
-
#removed ⇒ Object
readonly
Returns the value of attribute removed.
Instance Method Summary collapse
- #any? ⇒ Boolean
- #each ⇒ Object
- #empty? ⇒ Boolean
-
#initialize(added:, removed:, modified:) ⇒ Changeset
constructor
A new instance of Changeset.
- #to_h ⇒ Object
Constructor Details
#initialize(added:, removed:, modified:) ⇒ Changeset
Returns a new instance of Changeset.
5 6 7 8 9 10 11 |
# File 'lib/watchly/changeset.rb', line 5 def initialize(added:, removed:, modified:) @added = added.freeze @removed = removed.freeze @modified = modified.freeze @files = (added + modified).freeze freeze end |
Instance Attribute Details
#added ⇒ Object (readonly)
Returns the value of attribute added.
3 4 5 |
# File 'lib/watchly/changeset.rb', line 3 def added @added end |
#files ⇒ Object (readonly)
Returns the value of attribute files.
3 4 5 |
# File 'lib/watchly/changeset.rb', line 3 def files @files end |
#modified ⇒ Object (readonly)
Returns the value of attribute modified.
3 4 5 |
# File 'lib/watchly/changeset.rb', line 3 def modified @modified end |
#removed ⇒ Object (readonly)
Returns the value of attribute removed.
3 4 5 |
# File 'lib/watchly/changeset.rb', line 3 def removed @removed end |
Instance Method Details
#any? ⇒ Boolean
14 |
# File 'lib/watchly/changeset.rb', line 14 def any? = !empty? |
#each ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/watchly/changeset.rb', line 17 def each return enum_for(:each) unless block_given? added.each { |path| yield :added, path } removed.each { |path| yield :removed, path } modified.each { |path| yield :modified, path } end |
#empty? ⇒ Boolean
13 |
# File 'lib/watchly/changeset.rb', line 13 def empty? = files.empty? |
#to_h ⇒ Object
15 |
# File 'lib/watchly/changeset.rb', line 15 def to_h = { added: added, removed: removed, modified: modified, files: files } |