Sha256: d5a38e23927a20c1a26405c6ea9a92e6db7e1ecc677b5ce6de77f6b562b035fc

Contents?: true

Size: 585 Bytes

Versions: 1

Compression:

Stored size: 585 Bytes

Contents

require 'rom/mapper_compiler'

module ROM
  module SQL
    class MapperCompiler < ROM::MapperCompiler
      def visit_attribute(node)
        name, _, meta_options = node

        if meta_options[:wrapped]
          [extract_wrapped_name(node), from: meta_options[:alias]]
        else
          [name]
        end
      end

      private

      def extract_wrapped_name(node)
        _, _, meta_options = node
        unwrapped_name = meta_options[:alias].to_s.dup
        unwrapped_name.slice!("#{meta_options[:wrapped]}_")
        unwrapped_name.to_sym
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rom-sql-3.1.0 lib/rom/sql/mapper_compiler.rb