lib/helpers/collection.rb in view_models-1.5.4 vs lib/helpers/collection.rb in view_models-1.5.5
- old
+ new
@@ -2,10 +2,12 @@
module Helpers
module Rails
# Construct a view_model for a collection.
#
+ # TODO Think about moving it into view_model_for, or renaming it view_models_for.
+ #
def collection_view_model_for array_or_pagination, context = self
Collection.new array_or_pagination, context
end
# The Collection view_model helper has the purpose of presenting presentable collections.
@@ -14,19 +16,15 @@
# * Render as collection
# * Render a pagination
#
class Collection
+ # Delegate collection relevant methods to the collection.
#
- #
- methods_to_delegate = [Enumerable.instance_methods.map(&:to_sym),
- :length, :size, :empty?, :each, :exit,
- { :to => :@collection }].flatten
- self.delegate *methods_to_delegate
- def select *args, &block # active_support fail?
- @collection.select *args, &block
- end
+ self.delegate *[Enumerable.instance_methods, :length, :size, :empty?, :each, :exit, { :to => :@collection }].flatten
+ #
+ #
def initialize collection, context
@collection, @context = collection, context
end
# Renders a list (in the broadest sense of the word).
\ No newline at end of file