Permalink
Browse files

cleanup

  • Loading branch information...
1 parent a7a0037 commit 1862c3ac3a82de28d0019a8a16a7a3202263c07d @mkristian committed Dec 7, 2012
Showing with 0 additions and 39 deletions.
  1. +0 −39 lib/ixtlan/babel/model_filter.rb
View
39 lib/ixtlan/babel/model_filter.rb
@@ -24,56 +24,17 @@ def filter_array( models, options, &block )
end
def filter_data(model, data, config, &block)
-#puts "-" * 80
-#p data
- #methods = (options[:methods] || []).collect { |e| e.to_s }
- #config.methods.each do |m|
- # data[ m ] = model.send( m )
- #end
-
- #include_methods = include.is_a?(Array) ? include : include.keys
-
config.methods.each do |m|
unless data.include?(m)
data[ m ] = model.send( m.to_sym )
end
end
- # config.methods.each do |m|
- # unless data.include?(m)
- # val = model.send( m.to_sym )
- # if val.is_a?(Array) && val.first.is_a?( String )
- # data[ m ] = val
- # elsif val.respond_to?( :collect )
- # data[ m ] = val.collect { |i| block.call( i ) }
- # else
- # case val
- # when Fixnum
- # data[ m ] = val
- # when String
- # data[ m ] = val
- # when TrueClass
- # data[ m ] = val
- # else
- # data[ m ]= block.call( val )
- # end
- # end
- # end
- # end
result = {}
data.each do |k,v|
k = k.to_s
if v.respond_to? :attributes
result[ k ] = filter_data( v, block.call(v), config[ k ], &block ) if config.include?( k )
-
- # if include.include?(k.to_s)
- # case include
- # when Array
- # result[k.to_s] = filter_data(model.send(k), v, &block)
- # when Hash
- # result[k.to_s] = filter_data(model.send(k), v, include[k.to_s], &block)
- # end
- # end
elsif v.is_a? Array
result[ k ] = filter_array( v, config[ k ], &block ) if config.include?( k )
else

0 comments on commit 1862c3a

Please sign in to comment.