Sha256: fcb964bec28cd9118d6c0054c58b9fbf8d7531d80bd2c57991fde194349dec95
Contents?: true
Size: 697 Bytes
Versions: 1
Compression:
Stored size: 697 Bytes
Contents
module SoberSwag class Blueprint class Field def initialize(name, serializer, from: nil, &block) @name = name @root_serializer = serializer @from = from @block = block end attr_reader :name def serializer @serializer ||= @root_serializer.serializer.via_map(&transform_proc) end private def transform_proc if @block @block else key = @from || @name proc do |object, _| if object.respond_to?(key) object.public_send(key) else object[key] end end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sober_swag-0.1.0 | lib/sober_swag/blueprint/field.rb |