Class: FidoMetadata::Coercer::Objects
- Inherits:
-
Object
- Object
- FidoMetadata::Coercer::Objects
- Defined in:
- lib/fido_metadata/coercer/objects.rb
Instance Method Summary collapse
- #coerce(values) ⇒ Object
-
#initialize(klass) ⇒ Objects
constructor
A new instance of Objects.
Constructor Details
#initialize(klass) ⇒ Objects
Returns a new instance of Objects.
6 7 8 |
# File 'lib/fido_metadata/coercer/objects.rb', line 6 def initialize(klass) @klass = klass end |
Instance Method Details
#coerce(values) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/fido_metadata/coercer/objects.rb', line 10 def coerce(values) return unless values.is_a?(Array) return values if values.all? { |value| value.is_a?(@klass) } values.map { |value| @klass.from_json(value) } end |