Class: Nsync::Consumer::Change
- Inherits:
-
Struct
- Object
- Struct
- Nsync::Consumer::Change
- Defined in:
- lib/nsync/consumer.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#diff ⇒ Object
Returns the value of attribute diff.
-
#id ⇒ Object
Returns the value of attribute id.
Instance Method Summary collapse
- #a_data(parse_json = true) ⇒ Object
- #b_data(parse_json = true) ⇒ Object
- #data ⇒ Object
- #json_data(data) ⇒ Object
- #type ⇒ Object
Instance Attribute Details
#diff ⇒ Object
Returns the value of attribute diff
154 155 156 |
# File 'lib/nsync/consumer.rb', line 154 def diff @diff end |
#id ⇒ Object
Returns the value of attribute id
154 155 156 |
# File 'lib/nsync/consumer.rb', line 154 def id @id end |
Instance Method Details
#a_data(parse_json = true) ⇒ Object
171 172 173 174 |
# File 'lib/nsync/consumer.rb', line 171 def a_data(parse_json=true) val = diff.a_blob ? diff.a_blob.data : "" parse_json ? json_data(val) : val end |
#b_data(parse_json = true) ⇒ Object
176 177 178 179 |
# File 'lib/nsync/consumer.rb', line 176 def b_data(parse_json=true) val = diff.b_blob ? diff.b_blob.data : "" parse_json ? json_data(val) : val end |
#data ⇒ Object
181 182 183 |
# File 'lib/nsync/consumer.rb', line 181 def data @data ||= b_data end |
#json_data(data) ⇒ Object
155 156 157 158 159 |
# File 'lib/nsync/consumer.rb', line 155 def json_data(data) JSON.load(data) rescue {} end |
#type ⇒ Object
161 162 163 164 165 166 167 168 169 |
# File 'lib/nsync/consumer.rb', line 161 def type if diff.deleted_file :deleted elsif diff.new_file :added else :modified end end |