Sha256: 4d95380fff4d3910a319c99015d17c453a2901d72ddfc0c6aa430dc92e8cc8c5

Contents?: true

Size: 896 Bytes

Versions: 2

Compression:

Stored size: 896 Bytes

Contents

require_relative 'column_definition/presenter'
require_relative 'devise/definition'

module WebammToRails
  module Sources
    module Migrations
      class Columns
        def initialize(waml_definition:, table_definition:)
          @waml_definition = waml_definition
          @table_definition = table_definition
        end

        def collection
          columns.compact.uniq(&:name).map do |column|
            ::WebammToRails::Sources::Migrations::ColumnDefinition::Presenter.new(column: column).render
          end
        end

        private

        def columns
          @table_definition.columns + devise_columns
        end

        def devise_columns
          ::WebammToRails::Sources::Migrations::Devise::Definition.new(
            waml_definition: @waml_definition, table_name: @table_definition.table
          ).columns_collection
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
webamm_to_rails-7.0.1 lib/webamm_to_rails/sources/migrations/columns.rb
webamm_to_rails-7.0.0 lib/webamm_to_rails/sources/migrations/columns.rb