Class: Dryml::TagParameters

Inherits:
Hash
  • Object
show all
Defined in:
lib/dryml/tag_parameters.rb

Instance Method Summary collapse

Constructor Details

#initialize(parameters, exclude_names = nil) ⇒ TagParameters

Returns a new instance of TagParameters.



7
8
9
10
11
12
13
# File 'lib/dryml/tag_parameters.rb', line 7

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

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, default_content = "") ⇒ Object



15
16
17
18
19
20
21
# File 'lib/dryml/tag_parameters.rb', line 15

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

Instance Method Details

#[](param_name) ⇒ Object

Question: does this do anything? -Tom



26
27
28
# File 'lib/dryml/tag_parameters.rb', line 26

def [](param_name)
  fetch(param_name, nil)
end