Class: HALDecorator::SerializeHooks::Hook
- Inherits:
-
Object
- Object
- HALDecorator::SerializeHooks::Hook
- Defined in:
- lib/hal_decorator/serialize_hooks.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#resource ⇒ Object
readonly
Returns the value of attribute resource.
Instance Method Summary collapse
-
#initialize(&block) ⇒ Hook
constructor
A new instance of Hook.
- #run(resource, options, arg) ⇒ Object
Constructor Details
#initialize(&block) ⇒ Hook
Returns a new instance of Hook.
9 10 11 |
# File 'lib/hal_decorator/serialize_hooks.rb', line 9 def initialize(&block) @block = block end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/hal_decorator/serialize_hooks.rb', line 7 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
7 8 9 |
# File 'lib/hal_decorator/serialize_hooks.rb', line 7 def @options end |
#resource ⇒ Object (readonly)
Returns the value of attribute resource.
7 8 9 |
# File 'lib/hal_decorator/serialize_hooks.rb', line 7 def resource @resource end |
Instance Method Details
#run(resource, options, arg) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/hal_decorator/serialize_hooks.rb', line 13 def run(resource, , arg) @resource = resource @options = instance_exec(arg, &@block) if @block ensure @resource = nil @options = nil end |