Sha256: 13c4a08be78902370e8f027b61754007cc6405a9234aff5e4c611d9f7e9e28cf

Contents?: true

Size: 1.17 KB

Versions: 6

Compression:

Stored size: 1.17 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

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
refinerycms-0.9.7.15 vendor/plugins/refinery/lib/refinery/activity.rb
refinerycms-0.9.7.14 vendor/plugins/refinery/lib/refinery/activity.rb
refinerycms-0.9.7.13 vendor/plugins/refinery/lib/refinery/activity.rb
refinerycms-0.9.7.11 vendor/plugins/refinery/lib/refinery/activity.rb
refinerycms-0.9.7.10 vendor/plugins/refinery/lib/refinery/activity.rb
refinerycms-0.9.7.9 vendor/plugins/refinery/lib/refinery/activity.rb