Sha256: f1ab5d89f969a3192e407b9e4d9dc22562728f64c61f5dab3eab7b91b05a28a1

Contents?: true

Size: 1.78 KB

Versions: 1

Compression:

Stored size: 1.78 KB

Contents

##
# Outpost::Config
#
# Define configuration for Outpost
module Outpost
  class Config
    DEFAULTS = {
      :title_attributes           => [:name, :title],
      :excluded_form_fields       => ["id", "created_at", "updated_at"],
      :excluded_list_columns      => [],
      :user_class                 => "User",
      :authentication_attribute   => :email,
      :preferences                => [:order, :sort_mode]
    }
    
    # Pass a block to this method to define the configuration
    # If no block is passed, config will be defaults
    def self.configure
      yield Outpost.config if block_given?
      Outpost.config
    end
    
    # An array of models that should show up
    attr_writer :registered_models
    def registered_models
      @registered_models || []
    end
    
    attr_writer :preferences
    def preferences
      @preferences || DEFAULTS[:preferences]
    end

    attr_writer :user_class
    def user_class
      @user_class || DEFAULTS[:user_class]
    end

    # Which attribute to use to authenticate
    attr_writer :authentication_attribute
    def authentication_attribute
      @authentication_attribute || DEFAULTS[:authentication_attribute]
    end

    # Which attributes to look at for `to_title`
    attr_writer :title_attributes
    def title_attributes
      (@title_attributes ||= DEFAULTS[:title_attributes]) | [:simple_title]
    end
    
    # Ignore these attributes when building a basic form
    attr_writer :excluded_form_fields
    def excluded_form_fields
      (@excluded_form_fields ||= []) | DEFAULTS[:excluded_form_fields]
    end
    
    # Ignore these attributes when building a basic list
    attr_writer :excluded_list_columns
    def excluded_list_columns
      (@excluded_list_columns ||= []) | DEFAULTS[:excluded_list_columns]
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
outpost-cms-0.0.3 lib/outpost/config.rb