Class: TemplateParams::Assertion

Inherits:
Object
  • Object
show all
Defined in:
lib/template_params/assertion.rb

Overview

A simple assertion suitable for view template preconditions.

Class Method Summary collapse

Instance Method Summary collapse

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, options)
  @type = type
  @options = 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, options = {}, &block)
  new(type, options).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