Created
February 24, 2015 17:26
-
-
Save keikun17/66730eef92b351e96beb to your computer and use it in GitHub Desktop.
decorator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# from https://github.com/keikun17/yapos/blob/master/app/decorators/decorator.rb | |
require 'delegate' | |
class Decorator < SimpleDelegator | |
include ActionView::Helpers | |
include ActionView::Context | |
include Rails.application.routes.url_helpers | |
def self.decorate_collection(arr) | |
decorated_collection = [] | |
arr.each do |item| | |
decorated_collection << self.new(item) | |
end | |
decorated_collection | |
end | |
def decorated_object | |
__getobj__ | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example usage, I think: