Module: Fmt::Matchable

Included in:
Model, Token
Defined in:
lib/fmt/mixins/matchable.rb

Instance Method Summary collapse

Instance Method Details

#deconstructObject

Returns an Array representation of the object



22
23
24
# File 'lib/fmt/mixins/matchable.rb', line 22

def deconstruct
  to_h.values
end

#deconstruct_keys(keys = []) ⇒ Object

Returns a Hash representation of the object limited to the given keys



16
17
18
# File 'lib/fmt/mixins/matchable.rb', line 16

def deconstruct_keys(keys = [])
  to_h.select { _1 in keys }
end

#to_hObject

Hash representation of the Object (required for pattern matching)

Raises:



9
10
11
# File 'lib/fmt/mixins/matchable.rb', line 9

def to_h
  raise Error, "to_h must be implemented by including class"
end