Module: Wrapper
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/wrapper.rb,
lib/wrapper/version.rb
Overview
:nodoc:
Defined Under Namespace
Modules: ClassMethods
Constant Summary collapse
- VERSION =
'1.0.1'
Instance Method Summary collapse
-
#==(other) ⇒ Object
Compare
#selfor#resourceagainst the givenother. - #as_json(*args) ⇒ Object
- #initialize(resource) ⇒ Object
-
#model ⇒ Object
Returns the wrapped
#resource‘s class. -
#resource ⇒ Object
Returns the original, wrapped
#resource. -
#respond_to?(method) ⇒ Boolean
Check if an instance method is defined either in the presenter or for on the
#resource. - #to_param ⇒ Object
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object (private)
73 74 75 76 77 78 79 |
# File 'lib/wrapper.rb', line 73 def method_missing(method, *args, &block) if resource.respond_to?(method) resource.send(method, *args, &block) else super end end |
Instance Method Details
#==(other) ⇒ Object
Compare #self or #resource against the given other.
52 53 54 |
# File 'lib/wrapper.rb', line 52 def ==(other) super || resource == other end |
#as_json(*args) ⇒ Object
56 57 58 |
# File 'lib/wrapper.rb', line 56 def as_json(*args) resource.as_json(*args) end |
#initialize(resource) ⇒ Object
31 32 33 |
# File 'lib/wrapper.rb', line 31 def initialize(resource) @resource = resource end |
#model ⇒ Object
Returns the wrapped #resource‘s class.
45 46 47 |
# File 'lib/wrapper.rb', line 45 def model self.resource.class end |
#resource ⇒ Object
Returns the original, wrapped #resource.
38 39 40 |
# File 'lib/wrapper.rb', line 38 def resource @resource end |
#respond_to?(method) ⇒ Boolean
Check if an instance method is defined either in the presenter or for on the #resource.
68 69 70 |
# File 'lib/wrapper.rb', line 68 def respond_to?(method) super || resource.respond_to?(method) end |
#to_param ⇒ Object
60 61 62 |
# File 'lib/wrapper.rb', line 60 def to_param resource.to_param end |