Sha256: bae9ec18f590db04585f29a61b8b6e4daf0bc9d00a959ce0667fc85b1bb46303

Contents?: true

Size: 841 Bytes

Versions: 12

Compression:

Stored size: 841 Bytes

Contents

class Radiant::AdminUI::RegionPartials
  def initialize(template)
    @partials = Hash.new {|h,k| h[k] = "<strong>`#{k}' default partial not found!</strong>" }
    @template = template
  end
  
  def [](key)
    @partials[key.to_s]
  end
  
  def method_missing(method, *args, &block)
    if block_given?
      # Ruby 1.9.2 yields self in instance_eval... see https://gist.github.com/479572
      # lambdas are as strict as methods in 1.9.x, making sure that the args match, Procs are not.
      if RUBY_VERSION =~ /^1\.9/ and block.lambda? and block.arity != 1
        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."
      end
      @partials[method.to_s] = @template.capture(&block)
    else
      @partials[method.to_s]
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
radiant-1.1.4 lib/radiant/admin_ui/region_partials.rb
radiant-1.1.3 lib/radiant/admin_ui/region_partials.rb
radiant-1.1.2 lib/radiant/admin_ui/region_partials.rb
radiant-1.1.1 lib/radiant/admin_ui/region_partials.rb
radiant-1.1.0 lib/radiant/admin_ui/region_partials.rb
radiant-1.1.0.rc1 lib/radiant/admin_ui/region_partials.rb
radiant-1.1.0.beta lib/radiant/admin_ui/region_partials.rb
radiant-1.0.1 lib/radiant/admin_ui/region_partials.rb
radiant-1.1.0.alpha lib/radiant/admin_ui/region_partials.rb
radiant-1.0.0 lib/radiant/admin_ui/region_partials.rb
radiant-1.0.0.rc5 lib/radiant/admin_ui/region_partials.rb
radiant-1.0.0.rc4 lib/radiant/admin_ui/region_partials.rb