Sha256: a0c1f24f576375330360ad8ff387b273c7771377db1e79e9b619597a2482a7cc
Contents?: true
Size: 908 Bytes
Versions: 2
Compression:
Stored size: 908 Bytes
Contents
require 'transproc/all' module Hanami module Model # Mapping # # @since 0.1.0 class Mapping extend Transproc::Registry import Transproc::HashTransformations def initialize(&blk) @attributes = {} @r_attributes = {} instance_eval(&blk) @processor = @attributes.empty? ? ::Hash : t(:rename_keys, @attributes) end def t(name, *args) self.class[name, *args] end def model(entity) end def register_as(name) end def attribute(name, options) from = options.fetch(:from, name) @attributes[name] = from @r_attributes[from] = name end def process(input) @processor[input] end def reverse? @r_attributes.any? end def translate(attribute) @r_attributes.fetch(attribute) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
hanami-model-1.0.0.beta2 | lib/hanami/model/mapping.rb |
hanami-model-1.0.0.beta1 | lib/hanami/model/mapping.rb |