Sha256: a00ec7abf6db1cc4acafa0219408372be9d8cc4495915f4641af52bdf5a04c52
Contents?: true
Size: 1.5 KB
Versions: 2
Compression:
Stored size: 1.5 KB
Contents
module PufferPages module Liquid class PageDrop < ::Liquid::Drop delegate *(PufferPages::Page.statuses.map {|s| "#{s}?"} << {:to => :page}) delegate :id, :slug, :created_at, :updated_at, :to => :page def initialize page @page = page end def name @context ? page.render(page.name, @context) : page.name end %w(parent root ancestors self_and_ancestors children self_and_children siblings self_and_siblings descendants, self_and_descendants).each do |attribute| define_method attribute do instance_variable_get("@#{attribute}") || instance_variable_set("@#{attribute}", page.send(attribute)) end end def path controller.puffer_pages.puffer_page_path page.to_location end def url controller.puffer_pages.puffer_page_url page.to_location end def current? current_page && page == current_page end def ancestor? current_page && page.is_ancestor_of?(current_page) end def == other page == other.send(:page) end def before_method name page_part = page.inherited_page_part(name) page_part.handle(@context) if page_part && @context end private attr_reader :page def current_page @current_page ||= @context.registers[:page] if @context end def controller @controller ||= @context.registers[:controller] if @context end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
puffer_pages-0.5.1 | lib/puffer_pages/liquid/page_drop.rb |
puffer_pages-0.5.0 | lib/puffer_pages/liquid/page_drop.rb |