Sha256: 725bda8bb3b5b09318406bbd506fae1f9363754da03902dfc5c50fe729e9f66d

Contents?: true

Size: 930 Bytes

Versions: 8

Compression:

Stored size: 930 Bytes

Contents

# frozen_string_literal: true

module PgEngine
  class SiteBrand
    attr_accessor :default_site_brand

    def initialize
      @options = {}
    end

    def value_for(key)
      options = @options[key.to_sym]

      raise PgEngine::Error, "Key not found: #{key}" if options.nil?

      if Current.app_name.present? && options.keys.include?(Current.app_name)
        options[Current.app_name]
      elsif options.keys.include?(:default)
        options[:default]
      elsif default_site_brand.present? && options.keys.include?(default_site_brand)
        pg_warn('Default site brand chosen')

        options[default_site_brand]
      else
        # :nocov:
        raise PgEngine::Error, 'No site brand found'
        # :nocov:
      end
    end

    def method_missing(method)
      value_for(method)
    end

    def respond_to_missing?(method, include_private)
      @options.key?(method.to_sym) or super
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
pg_rails-7.6.27 pg_engine/lib/pg_engine/site_brand.rb
pg_rails-7.6.26 pg_engine/lib/pg_engine/site_brand.rb
pg_rails-7.6.25 pg_engine/lib/pg_engine/site_brand.rb
pg_rails-7.6.24 pg_engine/lib/pg_engine/site_brand.rb
pg_rails-7.6.24.pre.5 pg_engine/lib/pg_engine/site_brand.rb
pg_rails-7.6.24.pre.4 pg_engine/lib/pg_engine/site_brand.rb
pg_rails-7.6.24.pre.3 pg_engine/lib/pg_engine/site_brand.rb
pg_rails-7.6.23 pg_engine/lib/pg_engine/site_brand.rb