Sha256: 14bc79744ec77a9a4ae890f6749e45d19c21e74023e070adfe9bd4406b74572a
Contents?: true
Size: 769 Bytes
Versions: 1
Compression:
Stored size: 769 Bytes
Contents
module Alba # Representing nested attribute class NestedAttribute # @param key_transformation [Symbol] determines how to transform keys # @param block [Proc] class body def initialize(key_transformation: :none, &block) @key_transformation = key_transformation @block = block end # @param object [Object] the object being serialized # @param params [Hash] params Hash inherited from Resource # @return [Hash] hash serialized from running the class body in the object def value(object:, params:) resource_class = Alba.resource_class resource_class.transform_keys(@key_transformation) resource_class.class_eval(&@block) resource_class.new(object, params: params).serializable_hash end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
alba-2.3.0 | lib/alba/nested_attribute.rb |