Class: Refinery::Plugin
- Inherits:
-
Object
- Object
- Refinery::Plugin
- Defined in:
- lib/refinery/plugin.rb
Instance Attribute Summary collapse
-
#always_allow_access ⇒ Object
Returns the value of attribute always_allow_access.
-
#class_name ⇒ Object
Returns the value of attribute class_name.
-
#controller ⇒ Object
Returns the value of attribute controller.
-
#dashboard ⇒ Object
Returns the value of attribute dashboard.
-
#directory ⇒ Object
Returns the value of attribute directory.
-
#hide_from_menu ⇒ Object
Returns the value of attribute hide_from_menu.
-
#menu_match ⇒ Object
Returns the value of attribute menu_match.
-
#name ⇒ Object
Returns the value of attribute name.
-
#pathname ⇒ Object
Returns the value of attribute pathname.
-
#plugin_activity ⇒ Object
Returns the value of attribute plugin_activity.
-
#url ⇒ Object
Returns a hash that can be used to create a url that points to the administration part of the plugin.
Class Method Summary collapse
Instance Method Summary collapse
-
#activity ⇒ Object
Retrieve information about how to access the latest activities of this plugin.
-
#activity=(activities) ⇒ Object
Stores information that can be used to retrieve the latest activities of this plugin.
-
#activity_by_class_name(class_name) ⇒ Object
Given a record’s class name, find the related activity object.
-
#description ⇒ Object
Returns the internationalized version of the description.
-
#highlighted?(params) ⇒ Boolean
Used to highlight the current tab in the admin interface.
-
#title ⇒ Object
Returns the internationalized version of the title.
- #version ⇒ Object
- #version=(*args) ⇒ Object
Instance Attribute Details
#always_allow_access ⇒ Object
Returns the value of attribute always_allow_access.
4 5 6 |
# File 'lib/refinery/plugin.rb', line 4 def always_allow_access @always_allow_access end |
#class_name ⇒ Object
Returns the value of attribute class_name.
4 5 6 |
# File 'lib/refinery/plugin.rb', line 4 def class_name @class_name end |
#controller ⇒ Object
Returns the value of attribute controller.
4 5 6 |
# File 'lib/refinery/plugin.rb', line 4 def controller @controller end |
#dashboard ⇒ Object
Returns the value of attribute dashboard.
4 5 6 |
# File 'lib/refinery/plugin.rb', line 4 def dashboard @dashboard end |
#directory ⇒ Object
Returns the value of attribute directory.
4 5 6 |
# File 'lib/refinery/plugin.rb', line 4 def directory @directory end |
#hide_from_menu ⇒ Object
Returns the value of attribute hide_from_menu.
4 5 6 |
# File 'lib/refinery/plugin.rb', line 4 def @hide_from_menu end |
#menu_match ⇒ Object
Returns the value of attribute menu_match.
4 5 6 |
# File 'lib/refinery/plugin.rb', line 4 def @menu_match end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/refinery/plugin.rb', line 4 def name @name end |
#pathname ⇒ Object
Returns the value of attribute pathname.
4 5 6 |
# File 'lib/refinery/plugin.rb', line 4 def pathname @pathname end |
#plugin_activity ⇒ Object
Returns the value of attribute plugin_activity.
4 5 6 |
# File 'lib/refinery/plugin.rb', line 4 def plugin_activity @plugin_activity end |
#url ⇒ Object
Returns a hash that can be used to create a url that points to the administration part of the plugin.
59 60 61 |
# File 'lib/refinery/plugin.rb', line 59 def url @url end |
Class Method Details
.register {|plugin = self.new| ... } ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/refinery/plugin.rb', line 8 def self.register(&block) yield(plugin = self.new) raise "A plugin MUST have a name!: #{plugin.inspect}" if plugin.name.blank? # Set defaults. plugin. ||= %r{refinery/#{plugin.name}(/.+?)?$} plugin.always_allow_access ||= false plugin.dashboard ||= false plugin.class_name ||= plugin.name.camelize # add the new plugin to the collection of registered plugins ::Refinery::Plugins.registered << plugin end |
Instance Method Details
#activity ⇒ Object
Retrieve information about how to access the latest activities of this plugin.
34 35 36 |
# File 'lib/refinery/plugin.rb', line 34 def activity self.plugin_activity ||= [] end |
#activity=(activities) ⇒ Object
Stores information that can be used to retrieve the latest activities of this plugin
39 40 41 |
# File 'lib/refinery/plugin.rb', line 39 def activity=(activities) [activities].flatten.each { |activity| add_activity(activity) } end |
#activity_by_class_name(class_name) ⇒ Object
Given a record’s class name, find the related activity object.
44 45 46 |
# File 'lib/refinery/plugin.rb', line 44 def activity_by_class_name(class_name) self.activity.select{ |a| a.class_name == class_name.to_s.camelize } end |
#description ⇒ Object
Returns the internationalized version of the description
29 30 31 |
# File 'lib/refinery/plugin.rb', line 29 def description ::I18n.translate(['refinery', 'plugins', name, 'description'].join('.')) end |
#highlighted?(params) ⇒ Boolean
Used to highlight the current tab in the admin interface
49 50 51 |
# File 'lib/refinery/plugin.rb', line 49 def highlighted?(params) !!(params[:controller].try(:gsub, "admin/", "") =~ ) || (dashboard && params[:action] == 'error_404') end |
#title ⇒ Object
Returns the internationalized version of the title
24 25 26 |
# File 'lib/refinery/plugin.rb', line 24 def title ::I18n.translate(['refinery', 'plugins', name, 'title'].join('.')) end |