Sha256: d8433be9173a7fae28a6f14dbc74a62b85ad0e2da2715a9e9712ec01fd238b9a
Contents?: true
Size: 830 Bytes
Versions: 3
Compression:
Stored size: 830 Bytes
Contents
require 'seory' require 'active_support/all' module Seory class EmptyCondition < ::Seory::Error; end class PageContents def initialize(*conditions, &block) @conditions = block_given? ? block : conditions raise EmptyCondition if @conditions.blank? @contents = {} end def define(name, value = nil, &block) @contents[name] = block_given? ? block : value end def content_for(name) @contents[name] end def match?(controller) return true if @conditions == [:default] if @conditions.respond_to?(:call) @conditions.call(controller) else @conditions.include?(action_slug(controller)) end end private def action_slug(controller) [controller.controller_name, controller.action_name].join('#') end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
seory-0.0.3 | lib/seory/page_contents.rb |
seory-0.0.2 | lib/seory/page_contents.rb |
seory-0.0.1 | lib/seory/page_contents.rb |