Class: TemplateParams::Assertion
- Inherits:
-
Object
- Object
- TemplateParams::Assertion
- Defined in:
- lib/template_params/assertion.rb
Overview
A simple assertion suitable for view template preconditions.
Class Method Summary collapse
-
.assert(type = nil, options = {}, &block) ⇒ Object
Convenience constructor.
Instance Method Summary collapse
-
#apply(&block) ⇒ Object
Apply the instantiated assertion to the given block.
-
#initialize(type, options) ⇒ Assertion
constructor
A new instance of Assertion.
Constructor Details
#initialize(type, options) ⇒ Assertion
Returns a new instance of Assertion.
9 10 11 12 |
# File 'lib/template_params/assertion.rb', line 9 def initialize(type, ) @type = type @options = end |
Class Method Details
.assert(type = nil, options = {}, &block) ⇒ Object
Convenience constructor.
16 17 18 |
# File 'lib/template_params/assertion.rb', line 16 def self.assert(type = nil, = {}, &block) new(type, ).apply(&block) end |
Instance Method Details
#apply(&block) ⇒ Object
Apply the instantiated assertion to the given block.
22 23 24 |
# File 'lib/template_params/assertion.rb', line 22 def apply(&block) assert_type assert_defined(&block) end |