Class: Cleaner
- Inherits:
-
Object
- Object
- Cleaner
- Defined in:
- lib/suds/cleaner.rb
Direct Known Subclasses
ColumnConverterCleaner, ColumnFilterCleaner, DowncaseCleaner, RegexCleaner
Instance Attribute Summary collapse
-
#action ⇒ Object
Returns the value of attribute action.
-
#data ⇒ Object
Returns the value of attribute data.
Class Method Summary collapse
Instance Method Summary collapse
- #clean(data) ⇒ Object
-
#initialize(&b) ⇒ Cleaner
constructor
A new instance of Cleaner.
Constructor Details
#initialize(&b) ⇒ Cleaner
Returns a new instance of Cleaner.
5 6 7 |
# File 'lib/suds/cleaner.rb', line 5 def initialize &b block_given? ? @action = b : raise("The generic Cleaner must be provided a block.") end |
Instance Attribute Details
#action ⇒ Object
Returns the value of attribute action.
3 4 5 |
# File 'lib/suds/cleaner.rb', line 3 def action @action end |
#data ⇒ Object
Returns the value of attribute data.
3 4 5 |
# File 'lib/suds/cleaner.rb', line 3 def data @data end |
Class Method Details
.clean_array(array, &b) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/suds/cleaner.rb', line 9 def self.clean_array array, &b raise "Please provide either a hash or an array as the main parameter" unless Array === array array.each do |row| clean_hash row, &b end return array end |
.clean_hash(hash, &b) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/suds/cleaner.rb', line 17 def self.clean_hash hash, &b raise "Please provide either a hash or an array as the main parameter" unless Hash === hash hash.each do |k,v| b.call(k,v) end return hash end |
Instance Method Details
#clean(data) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/suds/cleaner.rb', line 26 def clean data @data = data self.class.clean_array(@data) do |k,v| @action.call(k,v) end end |