Sha256: 731a4ff9bb2fcf787d4e208477396ee7d1699418a015ae1aeb88652ae5481d9b

Contents?: true

Size: 1.17 KB

Versions: 29

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 => 10,
        :nested_with => [],
        :order => 'updated_at DESC',
        :title => nil,
        :updated_image => "edit.png",
        :url => nil,
        :url_prefix => ""
      }.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

29 entries across 29 versions & 2 rubygems

Version Path
jacobat-refinerycms-0.9.6.14 vendor/plugins/refinery/lib/refinery/activity.rb
refinerycms-0.9.6.34 vendor/plugins/refinery/lib/refinery/activity.rb
refinerycms-0.9.6.33 vendor/plugins/refinery/lib/refinery/activity.rb
refinerycms-0.9.6.32 vendor/plugins/refinery/lib/refinery/activity.rb
refinerycms-0.9.6.31 vendor/plugins/refinery/lib/refinery/activity.rb
refinerycms-0.9.6.30 vendor/plugins/refinery/lib/refinery/activity.rb
refinerycms-0.9.6.29 vendor/plugins/refinery/lib/refinery/activity.rb
refinerycms-0.9.6.28 vendor/plugins/refinery/lib/refinery/activity.rb
refinerycms-0.9.6.27 vendor/plugins/refinery/lib/refinery/activity.rb
refinerycms-0.9.6.26 vendor/plugins/refinery/lib/refinery/activity.rb
refinerycms-0.9.6.25 vendor/plugins/refinery/lib/refinery/activity.rb
refinerycms-0.9.6.24 vendor/plugins/refinery/lib/refinery/activity.rb
refinerycms-0.9.6.23 vendor/plugins/refinery/lib/refinery/activity.rb
refinerycms-0.9.6.22 vendor/plugins/refinery/lib/refinery/activity.rb
refinerycms-0.9.6.21 vendor/plugins/refinery/lib/refinery/activity.rb
refinerycms-0.9.6.19 vendor/plugins/refinery/lib/refinery/activity.rb
refinerycms-0.9.6.18 vendor/plugins/refinery/lib/refinery/activity.rb
refinerycms-0.9.6.17 vendor/plugins/refinery/lib/refinery/activity.rb
refinerycms-0.9.6.16 vendor/plugins/refinery/lib/refinery/activity.rb
refinerycms-0.9.6.15 vendor/plugins/refinery/lib/refinery/activity.rb