Module: Wowza::WillChange

Included in:
REST::Publisher
Defined in:
lib/wowza/will_change.rb

Class Method Summary collapse

Instance Method Summary collapse

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

#changedObject



20
21
22
# File 'lib/wowza/will_change.rb', line 20

def changed
  changed_attributes.keys
end

#changed?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/wowza/will_change.rb', line 16

def changed?
  !changed_attributes.empty?
end

#changed_attributesObject



28
29
30
# File 'lib/wowza/will_change.rb', line 28

def changed_attributes
  @changed_attributes ||= {}
end

#changesObject



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