Sha256: 63bad3f2697dc619f1b09bcb4f20c193cf503c7d144a14bb9fb3a8c49aca60ea

Contents?: true

Size: 922 Bytes

Versions: 5

Compression:

Stored size: 922 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' 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

5 entries across 5 versions & 1 rubygems

Version Path
pg_rails-7.6.22 pg_engine/lib/pg_engine/site_brand.rb
pg_rails-7.6.22.pre.3 pg_engine/lib/pg_engine/site_brand.rb
pg_rails-7.6.22.pre.2 pg_engine/lib/pg_engine/site_brand.rb
pg_rails-7.6.22.pre.1 pg_engine/lib/pg_engine/site_brand.rb
pg_rails-7.6.21 pg_engine/lib/pg_engine/site_brand.rb