Class: Refinery::Plugins
- Inherits:
-
Object
- Object
- Refinery::Plugins
- Extended by:
- Forwardable
- Includes:
- Enumerable
- Defined in:
- lib/refinery/plugins.rb
Class Method Summary collapse
Instance Method Summary collapse
- #find_by_name(name) ⇒ Object (also: #[])
- #find_by_title(title) ⇒ Object
- #first_in_menu_with_url ⇒ Object
- #first_url_in_menu ⇒ Object
-
#in_menu ⇒ Object
TODO: Review necessary?.
-
#initialize(*args) ⇒ Plugins
constructor
A new instance of Plugins.
- #names ⇒ Object
- #pathnames ⇒ Object
- #titles ⇒ Object
- #update_positions(plugin_list) ⇒ Object
Constructor Details
#initialize(*args) ⇒ Plugins
Returns a new instance of Plugins.
8 9 10 |
# File 'lib/refinery/plugins.rb', line 8 def initialize(*args) @plugins = Array.new(*args) end |
Class Method Details
.always_allowed ⇒ Object
57 58 59 |
# File 'lib/refinery/plugins.rb', line 57 def always_allowed new registered.select(&:always_allow_access) end |
.registered ⇒ Object
61 62 63 |
# File 'lib/refinery/plugins.rb', line 61 def registered @registered_plugins ||= new end |
Instance Method Details
#find_by_name(name) ⇒ Object Also known as: []
14 15 16 |
# File 'lib/refinery/plugins.rb', line 14 def find_by_name(name) detect { |plugin| plugin.name == name } end |
#find_by_title(title) ⇒ Object
19 20 21 |
# File 'lib/refinery/plugins.rb', line 19 def find_by_title(title) detect { |plugin| plugin.title == title } end |
#first_in_menu_with_url ⇒ Object
41 42 43 |
# File 'lib/refinery/plugins.rb', line 41 def find(&:landable?) end |
#first_url_in_menu ⇒ Object
45 46 47 |
# File 'lib/refinery/plugins.rb', line 45 def .try(:url) end |
#in_menu ⇒ Object
TODO: Review necessary?
24 25 26 27 |
# File 'lib/refinery/plugins.rb', line 24 def = reject(&:hide_from_menu) self.class.new((prioritised & ) | ) end |
#names ⇒ Object
29 30 31 |
# File 'lib/refinery/plugins.rb', line 29 def names map(&:name) end |
#pathnames ⇒ Object
33 34 35 |
# File 'lib/refinery/plugins.rb', line 33 def pathnames map(&:pathname).compact.uniq end |
#titles ⇒ Object
37 38 39 |
# File 'lib/refinery/plugins.rb', line 37 def titles map(&:title) end |
#update_positions(plugin_list) ⇒ Object
49 50 51 52 53 54 |
# File 'lib/refinery/plugins.rb', line 49 def update_positions(plugin_list) plugins = plugin_list.map {|p| find_by_name(p) }.reject(&:blank?) plugins.each_with_index do |plugin, index| plugin.update_attributes(position: index) end end |