Module: DataMapper::Property::DirtyMinder::Hooker
- Defined in:
- lib/dm-types/support/dirty_minder.rb
Constant Summary collapse
- MUTATION_METHODS =
{ ::Array => %w{ []= push << shift pop insert unshift delete delete_at replace fill clear slice! reverse! rotate! compact! flatten! uniq! collect! map! sort! sort_by! reject! delete_if! select! shuffle! }.select { |meth| ::Array.instance_methods.any? { |m| m.to_s == meth } }, ::Hash => %w{ []= store delete delete_if replace update delete rehash shift clear merge! reject! select! }.select { |meth| ::Hash.instance_methods.any? { |m| m.to_s == meth } }, }
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.extended(instance) ⇒ Object
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/dm-types/support/dirty_minder.rb', line 96 def self.extended(instance) # FIXME: DirtyMinder is currently unsupported on RBX, because unlike # the other supported Rubies, RBX core class (e.g. Array, Hash) # methods use #send(). In other words, the other Rubies don't use # #send() (they map directly to their C functions). # # The current methodology takes advantage of this by using #send() to # forward method invocations we've hooked. Supporting RBX will # require finding another way, possibly for all Rubies. In the # meantime, something is better than nothing. return if defined?(RUBY_ENGINE) and RUBY_ENGINE == 'rbx' return unless type = MUTATION_METHODS.keys.find { |k| instance.kind_of?(k) } instance.extend const_get("#{type}Hooks") end |
Instance Method Details
#track(resource, property) ⇒ Object
143 144 145 |
# File 'lib/dm-types/support/dirty_minder.rb', line 143 def track(resource, property) @resource, @property = resource, property end |