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 class name of the plugin.
-
#controller ⇒ Object
Returns the value of attribute controller.
-
#dashboard ⇒ Object
Returns the value of attribute dashboard.
-
#description ⇒ Object
readonly
Returns the internationalized version of the description.
-
#directory ⇒ Object
Returns the value of attribute directory.
-
#hide_from_menu ⇒ Object
Returns the value of attribute hide_from_menu.
-
#menu_match ⇒ Object
Returns a RegExp that matches, if the current page is part of the plugin.
-
#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.
-
#version ⇒ Object
Returns the value of attribute version.
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.
-
#always_allow_access? ⇒ Boolean
Returns true, if the user doesn’t require plugin access.
-
#dashboard? ⇒ Boolean
Special property to indicate that this plugin is the dashboard plugin.
-
#highlighted?(params) ⇒ Boolean
Used to highlight the current tab in the admin interface.
-
#title ⇒ Object
Returns the internationalized version of the title.
Instance Attribute Details
#always_allow_access ⇒ Object
Returns the value of attribute always_allow_access.
28 29 30 |
# File 'lib/refinery/plugin.rb', line 28 def always_allow_access @always_allow_access end |
#class_name ⇒ Object
Returns the class name of the plugin
35 36 37 |
# File 'lib/refinery/plugin.rb', line 35 def class_name @class_name end |
#controller ⇒ Object
Returns the value of attribute controller.
28 29 30 |
# File 'lib/refinery/plugin.rb', line 28 def controller @controller end |
#dashboard ⇒ Object
Returns the value of attribute dashboard.
28 29 30 |
# File 'lib/refinery/plugin.rb', line 28 def dashboard @dashboard end |
#description ⇒ Object (readonly)
Returns the internationalized version of the description
45 46 47 |
# File 'lib/refinery/plugin.rb', line 45 def description @description end |
#directory ⇒ Object
Returns the value of attribute directory.
28 29 30 |
# File 'lib/refinery/plugin.rb', line 28 def directory @directory end |
#hide_from_menu ⇒ Object
Returns the value of attribute hide_from_menu.
28 29 30 |
# File 'lib/refinery/plugin.rb', line 28 def @hide_from_menu end |
#menu_match ⇒ Object
Returns a RegExp that matches, if the current page is part of the plugin.
75 76 77 |
# File 'lib/refinery/plugin.rb', line 75 def @menu_match end |
#name ⇒ Object
Returns the value of attribute name.
28 29 30 |
# File 'lib/refinery/plugin.rb', line 28 def name @name end |
#pathname ⇒ Object
Returns the value of attribute pathname.
28 29 30 |
# File 'lib/refinery/plugin.rb', line 28 def pathname @pathname end |
#plugin_activity ⇒ Object
Returns the value of attribute plugin_activity.
28 29 30 |
# File 'lib/refinery/plugin.rb', line 28 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.
80 81 82 |
# File 'lib/refinery/plugin.rb', line 80 def url @url end |
#version ⇒ Object
Returns the value of attribute version.
28 29 30 |
# File 'lib/refinery/plugin.rb', line 28 def version @version end |
Class Method Details
.register {|plugin| ... } ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/refinery/plugin.rb', line 6 def self.register(&block) plugin = self.new yield plugin raise "A plugin MUST have a name!: #{plugin.inspect}" if plugin.name.blank? # Set the root as Rails::Engine.called_from will always be # vendor/engines/refinery/lib/refinery new_called_from = begin # Remove the line number from backtraces making sure we don't leave anything behind call_stack = caller.map { |p| p.split(':')[0..-2].join(':') } File.dirname(call_stack.detect { |p| p !~ %r[railties[\w\-\.]*/lib/rails|rack[\w\-\.]*/lib/rack] }) end klass = Class.new(Rails::Engine) klass.class_eval <<-RUBY def self.called_from; "#{new_called_from}"; end RUBY Object.const_set(plugin.class_name.to_sym, klass) end |
Instance Method Details
#activity ⇒ Object
Retrieve information about how to access the latest activities of this plugin.
50 51 52 |
# File 'lib/refinery/plugin.rb', line 50 def activity self.plugin_activity ||= [] end |
#activity=(activities) ⇒ Object
Stores information that can be used to retrieve the latest activities of this plugin
55 56 57 |
# File 'lib/refinery/plugin.rb', line 55 def activity=(activities) [activities].flatten.each { |activity| add_activity(activity) } end |
#always_allow_access? ⇒ Boolean
Returns true, if the user doesn’t require plugin access
60 61 62 |
# File 'lib/refinery/plugin.rb', line 60 def always_allow_access? @always_allow_access ||= false end |
#dashboard? ⇒ Boolean
Special property to indicate that this plugin is the dashboard plugin.
65 66 67 |
# File 'lib/refinery/plugin.rb', line 65 def dashboard? @dashboard ||= false end |
#highlighted?(params) ⇒ Boolean
Used to highlight the current tab in the admin interface
70 71 72 |
# File 'lib/refinery/plugin.rb', line 70 def highlighted?(params) (params[:controller] =~ self.) or (self.dashboard? and params[:action] == 'error_404') end |
#title ⇒ Object
Returns the internationalized version of the title
40 41 42 |
# File 'lib/refinery/plugin.rb', line 40 def title ::I18n.translate(['plugins', name, 'title'].join('.')) end |