Module: PageEngine
- Defined in:
- lib/page_engine.rb,
lib/page_engine/engine.rb,
lib/page_engine/helpers.rb,
lib/page_engine/version.rb,
lib/page_engine/defaults.rb,
lib/page_engine/exceptions.rb,
lib/page_engine/class_methods.rb,
lib/page_engine/instance_methods.rb,
lib/generators/page_engine/install/install_generator.rb
Defined Under Namespace
Modules: ClassMethods, Generators, InstanceMethods
Classes: Engine, PageEngineException
Constant Summary
collapse
- VERSION =
"0.0.5"
- PAGE_ENGINE_ROOT_PATH =
"#{File.dirname(__FILE__)}/../.."
- @@layouts =
['application']
- @@page_parts =
%w{ body left right header footer }
- @@statuses =
Extra page statuses added to the default values
%w{ Draft Published Review Hidden }
- @@filters =
%w{ none html textile markdown erb erb+textile }
- @@required_route_actions =
%w{ index show new edit create update }
- @@excluded_route_controllers =
[]
- @@excluded_route_controllers_regex =
/^admin.*/
- @@role_class =
'Role'
- @@author_class =
'current_user'
- @@current_viewer_helper =
'current_user'
Class Method Summary
collapse
Class Method Details
.available_routes(options = {}) ⇒ Object
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
# File 'lib/page_engine.rb', line 73
def self.available_routes(options = {})
options = {
:required_actions => @@required_route_actions,
:excluded_controllers => @@excluded_route_controllers,
:excluded_controller_regex => @@excluded_route_controllers_regex
}.merge!(options.symbolize_keys)
available = {}
controller_actions = Rails.application.routes.routes.map(&:requirements)
controller_actions.delete_if { |c| c.empty? || c[:controller] == 'rails/info' || c[:controller] == 'pages' || !options[:required_actions].include?(c[:action]) || options[:excluded_controllers].include?(c[:controller]) || c[:controller] =~ options[:excluded_controller_regex] }
controller_actions.each do |c|
available[c[:controller]] ||= []
available[c[:controller]] << c[:action]
end
available
end
|
.class_exists?(class_name) ⇒ Boolean
66
67
68
69
70
71
|
# File 'lib/page_engine.rb', line 66
def self.class_exists?(class_name)
klass = Module.const_get(class_name)
return klass.is_a?(Class)
rescue NameError
return false
end
|
.has_author? ⇒ Boolean
102
103
104
|
# File 'lib/page_engine.rb', line 102
def self.has_author?
!self.author_class.blank?
end
|
.has_viewers? ⇒ Boolean
106
107
108
|
# File 'lib/page_engine.rb', line 106
def self.has_viewers?
!self.current_viewer_helper.blank?
end
|
.setup {|_self| ... } ⇒ Object
94
95
96
|
# File 'lib/page_engine.rb', line 94
def self.setup
yield self
end
|
.statuses ⇒ Object
62
63
64
|
# File 'lib/page_engine.rb', line 62
def self.statuses
@@statuses
end
|
.statuses=(s) ⇒ Object
58
59
60
|
# File 'lib/page_engine.rb', line 58
def self.statuses=s
@@statuses += s if s.is_a?(Array)
end
|
.uses_roles? ⇒ Boolean
98
99
100
|
# File 'lib/page_engine.rb', line 98
def self.uses_roles?
!self.role_class.blank?
end
|