Class: ObservableObject::Watcher::WatcherDetect

Inherits:
Object
  • Object
show all
Defined in:
lib/observable_object.rb

Constant Summary collapse

DefaultMethods =
[  :<<, :[]=, :add, :add?, :capitalize!, :chomp!, :chop!, :clear, :collect!, :compact!, :concat, 
:delete, :delete!, :delete?, :delete_at, :delete_if, :downcase!, :encode!, :gsub!, :fill, 
:flatten!, :initialize_copy, :insert, :keep_if, :lstrip!, :map!, :merge!, :next!, :pop, :prepend, 
:push, :rehash, :reject!, :replace, :reverse!, :rotate!, :rstrip!, :scrub!, :select!, 
:shift, :shuffle!, :slice!, :sort!, :sort_by!, :squeeze!, :store, :strip!, :sub!, :subtract,
:succ!, :swapcase!, :tr!, :tr_s!, :uniq!, :unshift, :upcase!, :update ]
StringExceptionMethods =

doesn’t change the object in case of String

[ :delete ]

Instance Method Summary collapse

Constructor Details

#initialize(obj) ⇒ WatcherDetect



43
44
45
# File 'lib/observable_object.rb', line 43

def initialize(obj)
  @methods = obj.is_a?(String) ? DefaultMethods-StringExceptionMethods : DefaultMethods
end

Instance Method Details

#is_state_changing(obj, mname) ⇒ Object

nothing to do



49
50
51
# File 'lib/observable_object.rb', line 49

def is_state_changing(obj,mname)
  mname.match(/.+\!\z/) || @methods.include?(mname)
end

#rememberObject



46
47
48
# File 'lib/observable_object.rb', line 46

def remember
  # nothing to do
end