Module: Wowza::WillChange
- Included in:
- REST::Publisher
- Defined in:
- lib/wowza/will_change.rb
Class Method Summary collapse
Instance Method Summary collapse
- #changed ⇒ Object
- #changed? ⇒ Boolean
- #changed_attributes ⇒ Object
- #changes ⇒ Object
- #restore_attributes(attributes = changed) ⇒ Object
Class Method Details
.included(host) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/wowza/will_change.rb', line 4 def self.included(host) def host.track_changes(*attrs) attrs.each { |attr| track_change(attr) } end def host.track_change(attr) define_method(:will_change!) do |attr| attribute_will_change!(attr) end end end |
Instance Method Details
#changed ⇒ Object
20 21 22 |
# File 'lib/wowza/will_change.rb', line 20 def changed changed_attributes.keys end |
#changed? ⇒ Boolean
16 17 18 |
# File 'lib/wowza/will_change.rb', line 16 def changed? !changed_attributes.empty? end |
#changed_attributes ⇒ Object
28 29 30 |
# File 'lib/wowza/will_change.rb', line 28 def changed_attributes @changed_attributes ||= {} end |
#changes ⇒ Object
24 25 26 |
# File 'lib/wowza/will_change.rb', line 24 def changes Hash[changed.map { |attr| [attr, attribute_change(attr)] }] end |
#restore_attributes(attributes = changed) ⇒ Object
32 33 34 |
# File 'lib/wowza/will_change.rb', line 32 def restore_attributes(attributes = changed) attributes.each { |attr| restore_attribute! attr } end |