Sha256: 9cd0db7c485c6f1f36cf67599546d9b69da8583d78ab4a9a23e8e8ada88cbf34

Contents?: true

Size: 1.71 KB

Versions: 2

Compression:

Stored size: 1.71 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?
    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]

    # 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

    # 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

2 entries across 2 versions & 1 rubygems

Version Path
active_scaffold_config_list-3.2.1 lib/active_scaffold/config/config_list.rb
active_scaffold_config_list-3.2.0 lib/active_scaffold/config/config_list.rb