Sha256: a184ab48bbaba5c123ae21560554625df74c16055973d519687fdba4e9f7d2dc

Contents?: true

Size: 846 Bytes

Versions: 71

Compression:

Stored size: 846 Bytes

Contents

class TrustyCms::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/ && block.lambda? && (block.arity != 1)
        raise "You can only pass a proc ('Proc.new') or a lambda that takes exactly one arg (for self) to TrustyCms::AdminUI::RegionPartials' method_missing."
      end

      @partials[method.to_s] = @template.capture(&block)
    else
      @partials[method.to_s]
    end
  end
end

Version data entries

71 entries across 71 versions & 1 rubygems

Version Path
trusty-cms-6.3.1 lib/trusty_cms/admin_ui/region_partials.rb
trusty-cms-7.0.2 lib/trusty_cms/admin_ui/region_partials.rb
trusty-cms-7.0.1 lib/trusty_cms/admin_ui/region_partials.rb
trusty-cms-7.0.0 lib/trusty_cms/admin_ui/region_partials.rb
trusty-cms-6.3 lib/trusty_cms/admin_ui/region_partials.rb
trusty-cms-6.2.1 lib/trusty_cms/admin_ui/region_partials.rb
trusty-cms-6.2.2.1 lib/trusty_cms/admin_ui/region_partials.rb
trusty-cms-6.2.0 lib/trusty_cms/admin_ui/region_partials.rb
trusty-cms-6.1.2 lib/trusty_cms/admin_ui/region_partials.rb
trusty-cms-6.1.1 lib/trusty_cms/admin_ui/region_partials.rb
trusty-cms-6.0.5 lib/trusty_cms/admin_ui/region_partials.rb
trusty-cms-6.0.4 lib/trusty_cms/admin_ui/region_partials.rb
trusty-cms-6.0.3 lib/trusty_cms/admin_ui/region_partials.rb
trusty-cms-6.0.2 lib/trusty_cms/admin_ui/region_partials.rb
trusty-cms-6.0.1 lib/trusty_cms/admin_ui/region_partials.rb
trusty-cms-5.6.1 lib/trusty_cms/admin_ui/region_partials.rb
trusty-cms-6.0.0 lib/trusty_cms/admin_ui/region_partials.rb
trusty-cms-5.6.0 lib/trusty_cms/admin_ui/region_partials.rb
trusty-cms-5.5.9 lib/trusty_cms/admin_ui/region_partials.rb
trusty-cms-5.5.8 lib/trusty_cms/admin_ui/region_partials.rb