Class: Array
- Defined in:
- lib/simple_mapper/support/core_ext.rb,
lib/simple_mapper/support/bliss_serializer.rb,
lib/simple_mapper/default_plugins/options_to_query.rb
Instance Method Summary collapse
- #crawl(&block) ⇒ Object
- #except(element) ⇒ Object
-
#to_query(key) ⇒ Object
:nodoc:.
- #to_xml(options = {}) ⇒ Object
Instance Method Details
#crawl(&block) ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/simple_mapper/support/core_ext.rb', line 70 def crawl(&block) raise ArgumentError, "no block given" unless block_given? self.each do |v| k = self v = case block.arity when 1 yield(v) when 2 yield(k,v) when 3 yield(self,k,v) end if v.is_a?(Array) v.crawl(&block) elsif v.is_a?(Hash) v.crawl(&block) end end end |
#except(element) ⇒ Object
66 67 68 |
# File 'lib/simple_mapper/support/core_ext.rb', line 66 def except(element) reject {|e| e == element} end |
#to_query(key) ⇒ Object
:nodoc:
14 15 16 |
# File 'lib/simple_mapper/default_plugins/options_to_query.rb', line 14 def to_query(key) #:nodoc: collect { |value| value.to_query("#{key}[]") } * '&' end |
#to_xml(options = {}) ⇒ Object
91 92 93 |
# File 'lib/simple_mapper/support/bliss_serializer.rb', line 91 def to_xml(={}) collect {|e| e.to_xml()}.join('') end |