Sha256: 0a65f0978a47b3fe6868b19ff74ed8e938b30544a6a81bf7b458ec6687f6709f

Contents?: true

Size: 616 Bytes

Versions: 12

Compression:

Stored size: 616 Bytes

Contents

# frozen_string_literal: true

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

12 entries across 12 versions & 1 rubygems

Version Path
rom-sql-3.6.4 lib/rom/sql/mapper_compiler.rb
rom-sql-3.6.3 lib/rom/sql/mapper_compiler.rb
rom-sql-3.6.2 lib/rom/sql/mapper_compiler.rb
rom-sql-3.6.1 lib/rom/sql/mapper_compiler.rb
rom-sql-3.6.0 lib/rom/sql/mapper_compiler.rb
rom-sql-3.5.0 lib/rom/sql/mapper_compiler.rb
rom-sql-3.4.0 lib/rom/sql/mapper_compiler.rb
rom-sql-3.3.3 lib/rom/sql/mapper_compiler.rb
rom-sql-3.3.2 lib/rom/sql/mapper_compiler.rb
rom-sql-3.3.1 lib/rom/sql/mapper_compiler.rb
rom-sql-3.3.0 lib/rom/sql/mapper_compiler.rb
rom-sql-3.2.0 lib/rom/sql/mapper_compiler.rb