Class: DudePolicy::Dude
- Inherits:
-
Object
- Object
- DudePolicy::Dude
- Defined in:
- lib/dude_policy/dude.rb
Instance Attribute Summary collapse
-
#dude ⇒ Object
readonly
Returns the value of attribute dude.
Instance Method Summary collapse
-
#initialize(current_dude) ⇒ Dude
constructor
A new instance of Dude.
- #inspect ⇒ Object
- #method_missing(name, resource) ⇒ Object
-
#respond_to? ⇒ Boolean
RSpec mocks are checking if object responds to calls Due to fact that we use method_missing is delegating responsibility Dude class responds to all calls.
Constructor Details
#initialize(current_dude) ⇒ Dude
Returns a new instance of Dude.
5 6 7 |
# File 'lib/dude_policy/dude.rb', line 5 def initialize(current_dude) @dude = current_dude end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, resource) ⇒ Object
14 15 16 |
# File 'lib/dude_policy/dude.rb', line 14 def method_missing(name, resource) resource.policy.send(name, dude: dude) end |
Instance Attribute Details
#dude ⇒ Object (readonly)
Returns the value of attribute dude.
3 4 5 |
# File 'lib/dude_policy/dude.rb', line 3 def dude @dude end |
Instance Method Details
#inspect ⇒ Object
9 10 11 12 |
# File 'lib/dude_policy/dude.rb', line 9 def inspect id = "##{dude.id}" if dude.respond_to?(:id) "<#DudePolicy::Dude##{object_id} #{dude.class.name}#{id}>" end |
#respond_to? ⇒ Boolean
RSpec mocks are checking if object responds to calls Due to fact that we use method_missing is delegating responsibility Dude class responds to all calls
21 22 23 |
# File 'lib/dude_policy/dude.rb', line 21 def respond_to?(*) true end |