Class: SimpleContentManagement::SimplePagesConstraint
- Inherits:
-
Object
- Object
- SimpleContentManagement::SimplePagesConstraint
- Defined in:
- lib/simple_content_management/simple_pages_constraint.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ SimplePagesConstraint
constructor
A new instance of SimplePagesConstraint.
- #matches?(request) ⇒ Boolean
- #route_created_or_updated(route) ⇒ Object
Constructor Details
#initialize ⇒ SimplePagesConstraint
Returns a new instance of SimplePagesConstraint.
2 3 4 |
# File 'lib/simple_content_management/simple_pages_constraint.rb', line 2 def initialize @routes = SimpleContentManagement::SimpleRoute.all end |
Class Method Details
.instance ⇒ Object
19 20 21 |
# File 'lib/simple_content_management/simple_pages_constraint.rb', line 19 def self.instance @@instance ||= SimpleContentManagement::SimplePagesConstraint.send :new end |
Instance Method Details
#matches?(request) ⇒ Boolean
14 15 16 17 |
# File 'lib/simple_content_management/simple_pages_constraint.rb', line 14 def matches?(request) path = request.params[:path].chomp ".html" !@routes.find{ |route| route.path == path }.nil? end |
#route_created_or_updated(route) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/simple_content_management/simple_pages_constraint.rb', line 6 def route_created_or_updated(route) if !(existing_route = @routes.find{ |existing_route| existing_route.id == route.id }).nil? existing_route.reload else @routes << route end end |