Sha256: b53d64b6995b724aca336da284744834863b71ad7e9ef3920a2d6e6c0f3041e8
Contents?: true
Size: 1.26 KB
Versions: 1
Compression:
Stored size: 1.26 KB
Contents
# encoding: utf-8 shared_context "Faceter" do before do module Faceter # Transproc functions module Functions extend Transproc::Registry uses :map_array, from: Transproc::ArrayTransformations uses :rename_keys, from: Transproc::HashTransformations end # Nodes class List < AbstractMapper::Branch def transproc Functions[:map_array, super] end end class Rename < AbstractMapper::Node def initialize(old, options = {}) @old = old @new = options.fetch(:to) super end def transproc Functions[:rename_keys, @old => @new] end end # Rules class CompactLists < AbstractMapper::PairRule def optimize? left.is_a?(List) && right.is_a?(List) end def optimize List.new { left.entries + right.entries } end end # Registry class Mapper < AbstractMapper configure do command :list, Faceter::List command :rename, Faceter::Rename rule Faceter::CompactLists end end end # module Faceter end # before after { Object.send :remove_const, :Faceter } end # shared context
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
abstract_mapper-0.0.1 | spec/integration/faceter.rb |