class Seory::Runtime

Attributes

page_contents[R]

Public Class Methods

new(page_contents, view_context, fallback = nil) click to toggle source
# File lib/seory/runtime.rb, line 10
def initialize(page_contents, view_context, fallback = nil)
  @page_contents = page_contents
  @view_context  = view_context
  @fallback      = fallback

  extend build_assign_accessor_module(@page_contents.assign_name_accessors)
end

Public Instance Methods

assigns(name) click to toggle source
# File lib/seory/runtime.rb, line 18
def assigns(name)
  controller.view_assigns[name.to_s]
end
helper() click to toggle source
# File lib/seory/runtime.rb, line 26
def helper
  @view_context
end
misc(name) click to toggle source
# File lib/seory/runtime.rb, line 22
def misc(name)
  calculate_content_for(name)
end

Private Instance Methods

build_assign_accessor_module(names) click to toggle source
# File lib/seory/runtime.rb, line 52
def build_assign_accessor_module(names)
  Module.new do
    Array(names).each do |name|
      define_method(name) { assigns(name) }
    end
  end
end
calculate_content_for(name) click to toggle source
# File lib/seory/runtime.rb, line 36
def calculate_content_for(name)
  case page_content = lookup_content_for(name)
  when Symbol
    calculate_content_for(page_content)
  when ->(o) { o.respond_to?(:call) }
    instance_exec(&page_content)
  else
    page_content.to_s
  end
end
lookup_content_for(name) click to toggle source
# File lib/seory/runtime.rb, line 47
def lookup_content_for(name)
  @page_contents.content_for(name) || \
  @fallback.try {|fb| fb.content_for(name) }
end