Sha256: c893a4eb4669a00eb337972b440622a3691dfb4d857cb3499a7d17c7c63dc187

Contents?: true

Size: 1.3 KB

Versions: 31

Compression:

Stored size: 1.3 KB

Contents

module Refinery
  class Activity

    attr_accessor :class, :conditions, :created_image, :limit, :nested_with, :order, :title, :updated_image, :url, :url_prefix

    # for nested_with, pass in the reverse order of ancestry e.g. [parent.parent_of_parent, parent]
    def initialize(options={})
      {
        :class => nil,
        :conditions => nil,
        :created_image => "add.png",
        :limit => 7,
        :nested_with => [],
        :order => "updated_at DESC",
        :title => "title",
        :updated_image => "edit.png",
        :url => nil,
        :url_prefix => "edit"
      }.merge(options).each { |key,value| self.instance_variable_set(:"@#{key}", value) }
    end

    # to use in a URL like edit_admin_group_individuals_url(record.group, record)
    # which will help you if you're using nested routed.
    def nesting(record_string="record")
      self.nested_with.inject("") { |nest_chain, nesting| nest_chain << "#{record_string}.#{nesting}," }
    end

    def url_prefix
      "#{"#{@url_prefix}_".gsub("__", "_") if @url_prefix.present?}"
    end

    def url
      "#{self.url_prefix}#{@url ||= "admin_#{self.class.name.underscore.downcase}_url"}"
    end

    def class
      if @class.kind_of?(Class)
        @class
      else
        Object.const_get(@class.to_sym)
      end
    end

  end
end

Version data entries

31 entries across 31 versions & 2 rubygems

Version Path
refinerycms-core-0.9.9.21 lib/refinery/activity.rb
refinerycms-core-0.9.9.20 lib/refinery/activity.rb
refinerycms-core-0.9.9.19 lib/refinery/activity.rb
refinerycms-core-0.9.9.18 lib/refinery/activity.rb
refinerycms-core-0.9.9.17 lib/refinery/activity.rb
refinerycms-core-0.9.9.16 lib/refinery/activity.rb
refinerycms-core-0.9.9.15 lib/refinery/activity.rb
refinerycms-core-0.9.9.14 lib/refinery/activity.rb
refinerycms-core-0.9.9.13 lib/refinery/activity.rb
refinerycms-core-0.9.9.12 lib/refinery/activity.rb
refinerycms-core-0.9.9.11 lib/refinery/activity.rb
refinerycms-core-0.9.9.10 lib/refinery/activity.rb
refinerycms-core-0.9.9.9 lib/refinery/activity.rb
refinerycms-core-0.9.9.8 lib/refinery/activity.rb
refinerycms-core-0.9.9.7 lib/refinery/activity.rb
refinerycms-core-0.9.9.5 lib/refinery/activity.rb
refinerycms-core-0.9.9.4 lib/refinery/activity.rb
refinerycms-core-0.9.9.3 lib/refinery/activity.rb
refinerycms-core-0.9.9.2 lib/refinery/activity.rb
refinerycms-core-0.9.9.1 lib/refinery/activity.rb