Sha256: 183fc921e8379edd9139d47087dcc051e4aa74d0e0b769d9ffbb83562abae532

Contents?: true

Size: 1.98 KB

Versions: 6

Compression:

Stored size: 1.98 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)
    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

6 entries across 6 versions & 1 rubygems

Version Path
active_scaffold_config_list-3.2.9 lib/active_scaffold/config/config_list.rb
active_scaffold_config_list-3.2.8 lib/active_scaffold/config/config_list.rb
active_scaffold_config_list-3.2.7 lib/active_scaffold/config/config_list.rb
active_scaffold_config_list-3.2.6 lib/active_scaffold/config/config_list.rb
active_scaffold_config_list-3.2.5 lib/active_scaffold/config/config_list.rb
active_scaffold_config_list-3.2.4 lib/active_scaffold/config/config_list.rb