Sha256: 0b8c3f69c6a5a78e47684345ac2fb89dda4622f27c4aa7ebef8cdce5ea26372c

Contents?: true

Size: 688 Bytes

Versions: 4

Compression:

Stored size: 688 Bytes

Contents

module Storey
  class Suffixifier

    def self.suffixify(*args)
      self.new(*args).suffixify
    end

    def initialize(schema_name)
      @schema_name = schema_name
    end

    def suffixify
      schema_names.map do |schema_name|
        if schema_name =~ /\w+#{suffix}/ || native_schema?(schema_name)
          schema_name
        else
          "#{schema_name}#{suffix}"
        end
      end.join(', ')
    end

    private

    def schema_names
      @schema_names ||= @schema_name.split(',').map(&:strip)
    end

    def suffix
      Storey.configuration.suffix
    end

    def native_schema?(schema_name)
      NativeSchemaMatcher.matches?(schema_name)
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
storey-2.2.0 lib/storey/suffixifier.rb
storey-2.1.2 lib/storey/suffixifier.rb
storey-2.1.1 lib/storey/suffixifier.rb
storey-2.1.0 lib/storey/suffixifier.rb