Sha256: 90a80d1e3cbda692b20ad87cd7b368f28c1ebe6a607aa2737b4c73e9f8663197

Contents?: true

Size: 697 Bytes

Versions: 53

Compression:

Stored size: 697 Bytes

Contents

  module Dryml

    class NoParameterError < RuntimeError; end

    class TagParameters < Hash

      def initialize(parameters, exclude_names=nil)
        if exclude_names.blank?
          update(parameters)
        else
          parameters.each_pair { |k, v| self[k] = v unless k.in?(exclude_names) }
        end
      end

      def method_missing(name, default_content="")
        if name.to_s =~ /\?$/
          has_key?(name.to_s[0..-2].to_sym)
        else
          self[name]._?.call(default_content) || ""
        end
      end

      undef_method :default

      # Question: does this do anything? -Tom
      def [](param_name)
        fetch(param_name, nil)
      end

    end

  end

Version data entries

53 entries across 53 versions & 1 rubygems

Version Path
dryml-2.2.6 lib/dryml/tag_parameters.rb
dryml-2.2.5 lib/dryml/tag_parameters.rb
dryml-2.2.4 lib/dryml/tag_parameters.rb
dryml-2.2.3 lib/dryml/tag_parameters.rb
dryml-2.2.2 lib/dryml/tag_parameters.rb
dryml-2.2.1 lib/dryml/tag_parameters.rb
dryml-2.2.0 lib/dryml/tag_parameters.rb
dryml-2.1.2 lib/dryml/tag_parameters.rb
dryml-2.1.1 lib/dryml/tag_parameters.rb
dryml-2.1.0 lib/dryml/tag_parameters.rb
dryml-2.1.0.pre4 lib/dryml/tag_parameters.rb
dryml-2.1.0.pre3 lib/dryml/tag_parameters.rb
dryml-2.1.0.pre2 lib/dryml/tag_parameters.rb
dryml-2.1.0.pre1 lib/dryml/tag_parameters.rb
dryml-2.0.1 lib/dryml/tag_parameters.rb
dryml-2.0.0 lib/dryml/tag_parameters.rb
dryml-2.0.0.pre10 lib/dryml/tag_parameters.rb
dryml-2.0.0.pre9 lib/dryml/tag_parameters.rb
dryml-2.0.0.pre8 lib/dryml/tag_parameters.rb
dryml-1.3.3 lib/dryml/tag_parameters.rb