Sha256: ac01dd08c23add07b35808843870863c8afa5ec8597fb5dd9d117cb83be85430

Contents?: true

Size: 717 Bytes

Versions: 6

Compression:

Stored size: 717 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
      
      def [](param_name)
        fetch(param_name, nil)
      end
        
    end
    
  end
  
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
hobo-0.7.4 hobo_files/plugin/lib/hobo/dryml/tag_parameters.rb
hobo-0.7.5 hobo_files/plugin/lib/hobo/dryml/tag_parameters.rb
hobo-0.7.0 hobo_files/plugin/lib/hobo/dryml/tag_parameters.rb
hobo-0.7.1 hobo_files/plugin/lib/hobo/dryml/tag_parameters.rb
hobo-0.7.2 hobo_files/plugin/lib/hobo/dryml/tag_parameters.rb
hobo-0.7.3 hobo_files/plugin/lib/hobo/dryml/tag_parameters.rb