lib/yodel/models/core/functions/function.rb in yodel-0.0.1 vs lib/yodel/models/core/functions/function.rb in yodel-0.0.2

- old
+ new

@@ -120,10 +120,12 @@ changed(context, parent_context, params.first) when 'previous_value' previous_value(context, parent_context, params.first) when 'collect' collect(context, parent_context, params.first) + when 'flatten' + flatten(context) when 'majority' majority(context, parent_context, params.first) when 'count' count(context, parent_context, params.first) when 'invert' @@ -268,9 +270,14 @@ end def collect(context, parent_context, field) raise "Context to collect must respond to collect" unless context.respond_to?(:collect) context.collect {|item| execute(item, field, parent_context)} + end + + def flatten(context) + raise "Context to flatten must respond to flatten" unless context.respond_to?(:flatten) + context.flatten end def each(context, parent_context, statement) raise "Context to each must respond to each" unless context.respond_to?(:each) context.each {|item| execute(item, statement, parent_context)}