Class: DataMapper::Persevere::Proxy
- Inherits:
-
Object
- Object
- DataMapper::Persevere::Proxy
- Defined in:
- lib/persevere_adapter/enhance.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(target) ⇒ Proxy
constructor
A new instance of Proxy.
- #method_missing(method, *args, &block) ⇒ Object
- #raise(*args) ⇒ Object
Constructor Details
#initialize(target) ⇒ Proxy
Returns a new instance of Proxy.
38 39 40 41 |
# File 'lib/persevere_adapter/enhance.rb', line 38 def initialize(target) @target = target end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
43 44 45 |
# File 'lib/persevere_adapter/enhance.rb', line 43 def method_missing(method, *args, &block) @target.send(method, *args, &block) end |
Class Method Details
.[](target) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/persevere_adapter/enhance.rb', line 16 def self.[](target) proxy = self.new(target) case target when DataMapper::Resource proxy.extend(JSONSupport::Core) proxy.extend(JSONSupport::Resource) when DataMapper::Model proxy.extend(JSONSupport::Core) proxy.extend(JSONSupport::Model) proxy.extend(JSONSupport::Model::Properties) when DataMapper::Property proxy.extend(JSONSupport::Core) proxy.extend(JSONSupport::Property) when DataMapper::Query proxy.extend(Persevere::Query) else return target end return proxy end |
Instance Method Details
#raise(*args) ⇒ Object
12 13 14 |
# File 'lib/persevere_adapter/enhance.rb', line 12 def raise(*args) ::Object.send(:raise, *args) end |