Class: ObjectForge::Molds::MoldMold
- Inherits:
-
Object
- Object
- ObjectForge::Molds::MoldMold
- Defined in:
- lib/object_forge/molds/mold_mold.rb
Overview
Special “mold” that returns appropriate mold for the given forged object. Probably not the best fit though.
Currently provides specific recognition for:
-
subclasses of
Struct(StructMold), -
subclasses of
Data(KeywordsMold), -
Hashand subclasses (HashMold).
Other objects just get SingleArgumentMold.
Instance Method Summary collapse
-
#call(forged:, **_) ⇒ #call
Get maybe appropriate mold for the given forged object.
Instance Method Details
#call(forged:, **_) ⇒ #call
Get maybe appropriate mold for the given forged object.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/object_forge/molds/mold_mold.rb', line 21 def call(forged:, **_) # rubocop:disable Style/YodaCondition if ::Class === forged if ::Struct > forged StructMold.new elsif defined?(::Data) && ::Data > forged KeywordsMold.new elsif ::Hash >= forged HashMold.new else SingleArgumentMold.new end else SingleArgumentMold.new end # rubocop:enable Style/YodaCondition end |