File: lib/radiant/admin_ui/region_partials.rb

Overview
Module Structure
Class Hierarchy
Code

Overview

Module Structure

  module: <Toplevel Module>
  module: Radiant
  class: AdminUI
  class: RegionPartials#1
inherits from
  Object ( Builtin-Module )
has properties
method: initialize / 1 #2
method: [] / 1 #7
method: method_missing / 3 #11

Class Hierarchy

Code

   1  class Radiant::AdminUI::RegionPartials
   2    def initialize(template)
   3      @partials = Hash.new {|h,k| h[k] = "<strong>`#{k}' default partial not found!</strong>" }
   4      @template = template
   5    end
   6    
   7    def [](key)
   8      @partials[key.to_s]
   9    end
  10    
  11    def method_missing(method, *args, &block)
  12      if block_given?
  13        # Ruby 1.9.2 yields self in instance_eval... see https://gist.github.com/479572
  14        # lambdas are as strict as methods in 1.9.x, making sure that the args match, Procs are not.
  15        if RUBY_VERSION =~ /^1\.9/ and block.lambda? and block.arity != 1
  16          raise "You can only pass a proc ('Proc.new') or a lambda that takes exactly one arg (for self) to Radiant::AdminUI::RegionPartials' method_missing."
  17        end
  18        @partials[method.to_s] = @template.capture(&block)
  19      else
  20        @partials[method.to_s]
  21      end
  22    end
  23  en