Class: Contracts::IsA

Inherits:
Callable show all
Defined in:
lib/middleman-core/contracts.rb,
lib/middleman-core/contracts.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(val) ⇒ IsA

Returns a new instance of IsA.



12
13
14
# File 'lib/middleman-core/contracts.rb', line 12

def initialize(val)
  @val = val
end

Class Method Details

.[](val) ⇒ Object



7
8
9
10
# File 'lib/middleman-core/contracts.rb', line 7

def self.[](val)
  @lookup ||= {}
  @lookup[val] ||= new(val)
end

Instance Method Details

#valid?(val) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/middleman-core/contracts.rb', line 16

def valid?(val)
  val.is_a? @val.constantize
end