Module: Hancock
- Includes:
- Plugin, PluginConfiguration
- Defined in:
- lib/hancock_cms.rb,
lib/hancock/admin.rb,
lib/hancock/model.rb,
lib/hancock/engine.rb,
lib/hancock/version.rb,
lib/hancock/migration.rb,
lib/hancock/configuration.rb,
lib/hancock/admin/embedded_element.rb,
lib/hancock/rails_admin_ext/config.rb,
app/models/hancock/embedded_element.rb,
lib/hancock/models/embedded_element.rb,
lib/hancock/rails_admin_settings_patch.rb,
app/controllers/hancock/home_controller.rb,
lib/hancock/models/mongoid/embedded_element.rb,
app/models/concerns/hancock/embedded_findable.rb
Defined Under Namespace
Modules: Admin, BooleanField, Cms, Controller, Controllers, CurrentUser, Decorators, EmbeddedFindable, Enableable, Errors, Fancybox, Geocodeable, GzipHelper, HashField, HomeHelper, HtmlField, InsertionField, Mappable, MasterCollection, Migration, Model, ModelLocalizeable, Models, Plugin, PluginConfiguration, PoweredHelper, RailsAdminGroupPatch, RailsAdminPatch, RailsAdminSettingsPatch, SettingsHelper, SortField, Sortable, UserDefined
Classes: Configuration, EmbeddedElement, Engine, HomeController, RailsAdminConfiguration, RegistrationsController, SessionsController
Constant Summary
collapse
- MODELS =
[]
- PLUGINS =
[]
- VERSION =
"2.0.1.3".freeze
Class Method Summary
collapse
included
Methods included from Plugin
included
Class Method Details
.action_unvisible_for(action_name, model_name) ⇒ Object
16
17
18
|
# File 'lib/hancock/rails_admin_ext/config.rb', line 16
def action_unvisible_for(action_name, model_name)
rails_admin_config.action_unvisible_for action_name, model_name
end
|
.action_visible_for(action_name, model_name) ⇒ Object
13
14
15
|
# File 'lib/hancock/rails_admin_ext/config.rb', line 13
def action_visible_for(action_name, model_name)
rails_admin_config.action_visible_for action_name, model_name
end
|
.cancancan_admin_rules(ability_object) ⇒ Object
24
25
26
|
# File 'lib/hancock/rails_admin_ext/config.rb', line 24
def cancancan_admin_rules(ability_object)
rails_admin_config.cancancan_admin_rules(ability_object)
end
|
.cancancan_manager_rules(ability_object) ⇒ Object
27
28
29
|
# File 'lib/hancock/rails_admin_ext/config.rb', line 27
def cancancan_manager_rules(ability_object)
rails_admin_config.cancancan_manager_rules(ability_object)
end
|
.clear_history! ⇒ Object
100
101
102
|
# File 'lib/hancock_cms.rb', line 100
def clear_history!
::HistoryTracker.delete_all if defined?(::HistoryTracker)
end
|
.clear_history_from_empty_objects ⇒ Object
87
88
89
90
91
92
93
94
95
96
97
98
|
# File 'lib/hancock_cms.rb', line 87
def clear_history_from_empty_objects
::HistoryTracker.all.map do |h|
begin
begin
h.delete if h.trackable.nil?
rescue
h.delete
end
rescue
end
end if defined?(::HistoryTracker)
end
|
.config(plugin_name = nil) ⇒ Object
30
31
32
|
# File 'lib/hancock/configuration.rb', line 30
def self.config(plugin_name = nil)
configuration(plugin_name)
end
|
.config_class ⇒ Object
34
35
36
|
# File 'lib/hancock/configuration.rb', line 34
def self.config_class
Configuration
end
|
.configuration(plugin_name = nil) ⇒ Object
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/hancock/configuration.rb', line 4
def self.configuration(plugin_name = nil)
return @configuration ||= config_class.new if config_class if plugin_name.blank?
@plugins_cache ||= {}
_plugin = nil
_plugin = plugin_name if Hancock::PLUGINS.include?(plugin_name)
if _plugin.nil?
plugin_name = plugin_name.to_s.camelize
return _plugin.config unless (_plugin = @plugins_cache[plugin_name]).nil?
if Object.const_defined?(plugin_name)
_plugin_name_const = plugin_name.constantize
_plugin = _plugin_name_const if Hancock::PLUGINS.include?(_plugin_name_const) or _plugin_name_const == Hancock
end
end
if _plugin.nil?
if Object.const_defined?("Hancock::#{plugin_name}")
_plugin_name_const = "Hancock::#{plugin_name}".constantize
_plugin = _plugin_name_const if Hancock::PLUGINS.include?(_plugin_name_const)
end
end
if _plugin
@plugins_cache[plugin_name] = _plugin
return _plugin.config
end
return nil
end
|
38
39
40
41
|
# File 'lib/hancock/configuration.rb', line 38
def self.configure
yield configuration
Hancock::PLUGINS.map(&:reconfigure!)
end
|
.rails4? ⇒ Boolean
71
72
73
|
# File 'lib/hancock_cms.rb', line 71
def rails4?
false
end
|
.rails5? ⇒ Boolean
75
76
77
|
# File 'lib/hancock_cms.rb', line 75
def rails5?
true
end
|
.rails_admin_config ⇒ Object
6
7
8
|
# File 'lib/hancock/rails_admin_ext/config.rb', line 6
def rails_admin_config
@rails_admin_configuration ||= RailsAdminConfiguration.new
end
|
.rails_admin_config_for_actions(actions) ⇒ Object
20
21
22
|
# File 'lib/hancock/rails_admin_ext/config.rb', line 20
def rails_admin_config_for_actions(actions)
rails_admin_config.actions_config(actions)
end
|
.rails_admin_configuration ⇒ Object
3
4
5
|
# File 'lib/hancock/rails_admin_ext/config.rb', line 3
def rails_admin_configuration
@rails_admin_configuration ||= RailsAdminConfiguration.new
end
|
9
10
11
|
# File 'lib/hancock/rails_admin_ext/config.rb', line 9
def rails_admin_configure
yield rails_admin_configuration
end
|
.register_model(model) ⇒ Object
80
81
82
|
# File 'lib/hancock_cms.rb', line 80
def register_model(model)
Hancock::MODELS << model unless Hancock::MODELS.include?(model)
end
|
.register_plugin(plugin) ⇒ Object
83
84
85
|
# File 'lib/hancock_cms.rb', line 83
def register_plugin(plugin)
Hancock::PLUGINS << plugin unless Hancock::PLUGINS.include?(plugin)
end
|