module DroidServices::Extensions::HasDecorator
Public Instance Methods
decorated_collection()
click to toggle source
# File lib/droid_services/extensions/has_decorator.rb, line 15 def decorated_collection if decorable? build_decorated_collection else build_collection end end
Private Instance Methods
build_decorated_collection()
click to toggle source
# File lib/droid_services/extensions/has_decorator.rb, line 45 def build_decorated_collection prepare_collection_for_decorate.map{|i| decorator_class.new(i)} end
decorable?()
click to toggle source
# File lib/droid_services/extensions/has_decorator.rb, line 25 def decorable? !self.class.decorator_class_name.nil? end
decorator_class()
click to toggle source
# File lib/droid_services/extensions/has_decorator.rb, line 29 def decorator_class self.class.decorator_class_name.to_s.classify.constantize end
prepare_collection_for_decorate()
click to toggle source
# File lib/droid_services/extensions/has_decorator.rb, line 33 def prepare_collection_for_decorate collection = build_collection if collection.kind_of?(Array) return collection elsif collection.respond_to?(:all) return collection.all else return Array.wrap(collection) end end