Class: Filtrum::TypeSerializer

Inherits:
Object
  • Object
show all
Defined in:
lib/filtrum/type_serializer.rb

Instance Method Summary collapse

Constructor Details

#initialize(type, block) ⇒ TypeSerializer

Returns a new instance of TypeSerializer.



5
6
7
# File 'lib/filtrum/type_serializer.rb', line 5

def initialize type, block
  @type, @block = type, block
end

Instance Method Details

#match?(value) ⇒ Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/filtrum/type_serializer.rb', line 9

def match? value
  value.kind_of? @type
end

#serialize(value) ⇒ Object



13
14
15
# File 'lib/filtrum/type_serializer.rb', line 13

def serialize value
  @block.call value
end