Sha256: 2282b3ec34278e7f27738992097e771e25f0796bffdb55515e3bf0719d9d1980

Contents?: true

Size: 716 Bytes

Versions: 19

Compression:

Stored size: 716 Bytes

Contents

module Hobo

  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

end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
hobo-1.0.3 lib/hobo/dryml/tag_parameters.rb
hobo-1.0.2 lib/hobo/dryml/tag_parameters.rb
hobo-1.0.1 lib/hobo/dryml/tag_parameters.rb
hobo-1.0.0 lib/hobo/dryml/tag_parameters.rb
hobo-0.9.106 lib/hobo/dryml/tag_parameters.rb
hobo-0.9.105 lib/hobo/dryml/tag_parameters.rb
hobo-0.9.104 lib/hobo/dryml/tag_parameters.rb
hobo-0.9.103 lib/hobo/dryml/tag_parameters.rb
hobo-0.9.102 lib/hobo/dryml/tag_parameters.rb
hobo-0.9.101 lib/hobo/dryml/tag_parameters.rb
hobo-0.9.100 lib/hobo/dryml/tag_parameters.rb
hobo-0.9.0 lib/hobo/dryml/tag_parameters.rb
hobo-0.8.10 lib/hobo/dryml/tag_parameters.rb
hobo-0.8.9 lib/hobo/dryml/tag_parameters.rb
hobo-0.8.8 lib/hobo/dryml/tag_parameters.rb
hobo-0.8.5 lib/hobo/dryml/tag_parameters.rb
hobo-0.8.4 lib/hobo/dryml/tag_parameters.rb
hobo-0.8.7 lib/hobo/dryml/tag_parameters.rb
hobo-0.8.6 lib/hobo/dryml/tag_parameters.rb