Sha256: 491dea14e9cf720c33ae196b0bea8ef6b5f1a1af8914fcdab659d496c7bd9c4c

Contents?: true

Size: 2 KB

Versions: 4

Compression:

Stored size: 2 KB

Contents

module ActiveScaffold::Config
  class ConfigList < Base
    self.crud_type = :read
    def initialize(*args)
      super
      @link = self.class.link.clone unless self.class.link.nil?
      @save_to_user = self.class.save_to_user
    end

    # global level configuration
    # --------------------------
    # the ActionLink for this action
    def self.link
      @@link
    end
    def self.link=(val)
      @@link = val
    end
    @@link = ActiveScaffold::DataStructures::ActionLink.new('show_config_list', :label => :config_list, :type => :collection, :security_method => :config_list_authorized?)

    # configures where the plugin itself is located. there is no instance version of this.
    cattr_accessor :plugin_directory
    @@plugin_directory = File.expand_path(__FILE__).match(%{(^.*)/lib/active_scaffold/config/config_list.rb})[1]

    # configures the method in user model to save list configuration for every controller
    cattr_accessor :save_to_user

    # instance-level configuration
    # ----------------------------
    # the label= method already exists in the Form base class
    def label
      @label ? as_(@label) : as_(:config_list_model, :model => @core.label.singularize)
    end

    # if you do not want to show all columns as a default you may define some
    # e.g. conf.config_list.default_columns = [:name, founded_on]
    attr_accessor :default_columns

    # configures the method in user model to save list configuration for every controller
    attr_accessor :save_to_user

    # provides access to the list of columns specifically meant for the config_list to use
    def columns
      unless @columns # lazy evaluation
        self.columns = @core.columns._inheritable
        self.columns.exclude :created_on, :created_at, :updated_on, :updated_at, :as_marked
        self.columns.exclude *@core.columns.collect{|c| c.name if c.polymorphic_association?}.compact
      end
      @columns
    end
    
    public :columns=
    
    # the ActionLink for this action
    attr_accessor :link
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
active_scaffold_config_list-3.2.3 lib/active_scaffold/config/config_list.rb
active_scaffold_config_list-3.2.2.2 lib/active_scaffold/config/config_list.rb
active_scaffold_config_list-3.2.2.1 lib/active_scaffold/config/config_list.rb
active_scaffold_config_list-3.2.2 lib/active_scaffold/config/config_list.rb