Sha256: 66f356dbb89a91fb7dab2b435c2a3704f2d66ace298e34870ccb0694bfb02fda

Contents?: true

Size: 1.88 KB

Versions: 33

Compression:

Stored size: 1.88 KB

Contents

module ActiveScaffold::Config
  class Base
    include ActiveScaffold::Configurable
    extend ActiveScaffold::Configurable

    def initialize(core_config)
      @core = core_config
    end

    def self.inherited(subclass)
      class << subclass
        # the crud type of the action. possible values are :create, :read, :update, :delete, and nil.
        # this is not a setting for the developer. it's self-description for the actions.
        def crud_type; @crud_type; end

        protected

        def crud_type=(val)
          raise ArgumentError, "unknown CRUD type #{val}" unless [:create, :read, :update, :delete].include?(val.to_sym)
          @crud_type = val.to_sym
        end
      end
    end

    # delegate
    def crud_type; self.class.crud_type end

    def label(model = nil)
      model ||= @core.label(:count => 1)
      @label.nil? ? model : as_(@label, :model => model)
    end
    
    # the user property gets set to the instantiation of the local UserSettings class during the automatic instantiation of this class.
    attr_accessor :user

    # define a default action_group for this action
    # e.g. 'members.crud'
    class_attribute :action_group

    # action_group this action should belong to
    attr_accessor :action_group

    class UserSettings
      def initialize(conf, storage, params)
        # the session hash relevant to this action
        @session = storage
        # all the request params
        @params = params
        # the configuration object for this action
        @conf = conf
      end
    end
    
    def formats
      @formats ||= []
    end
    
    def formats=(val)
      @formats=val
    end
    
    private
    
    def columns=(val)
      @columns = ActiveScaffold::DataStructures::ActionColumns.new(*val)
      @columns.action = self
      @columns.set_columns(@core.columns) if @columns.respond_to?(:set_columns)
      @columns
    end
  end
end

Version data entries

33 entries across 33 versions & 2 rubygems

Version Path
active_scaffold-sequel-0.8.0 lib/active_scaffold/config/base.rb
active_scaffold-sequel-0.7.1 lib/active_scaffold/config/base.rb
active_scaffold-sequel-0.7.0 lib/active_scaffold/config/base.rb
active_scaffold-sequel-0.6.2 lib/active_scaffold/config/base.rb
active_scaffold-sequel-0.6.1 lib/active_scaffold/config/base.rb
active_scaffold-sequel-0.6.0 lib/active_scaffold/config/base.rb
active_scaffold-3.2.8 lib/active_scaffold/config/base.rb
active_scaffold-3.2.7 lib/active_scaffold/config/base.rb
active_scaffold-3.2.6 lib/active_scaffold/config/base.rb
active_scaffold-3.2.5 lib/active_scaffold/config/base.rb
active_scaffold-3.2.4 lib/active_scaffold/config/base.rb
active_scaffold-3.2.3 lib/active_scaffold/config/base.rb
active_scaffold-sequel-0.5.1 lib/active_scaffold/config/base.rb
active_scaffold-sequel-0.5.0 lib/active_scaffold/config/base.rb
active_scaffold-3.2.2 lib/active_scaffold/config/base.rb
active_scaffold-3.2.1 lib/active_scaffold/config/base.rb
active_scaffold-sequel-0.4.0 lib/active_scaffold/config/base.rb
active_scaffold-sequel-0.3.0 lib/active_scaffold/config/base.rb
active_scaffold-3.2.0 lib/active_scaffold/config/base.rb
active_scaffold-3.1.20 lib/active_scaffold/config/base.rb