Module: Parts::Helpers
- Defined in:
- lib/parts/helpers.rb
Instance Method Summary collapse
Instance Method Details
#part(opts = {}) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/parts/helpers.rb', line 3 def part(opts = {}) klasses, opts = opts.partition do |k,v| k.respond_to?(:ancestors) && k.ancestors.include?(Parts::Base) end opts = opts.inject({}) {|h,v| h[v.first] = v.last; h} res = klasses.inject([]) do |memo,(klass,action)| part = klass.new(self, opts) part.process(action) memo << part.response_body end res.size == 1 ? res[0] : res end |