Created
July 26, 2018 08:55
-
-
Save lujanfernaud/96d53a294ac2cf44a46d14b1228dc476 to your computer and use it in GitHub Desktop.
Rails: Simple 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
# frozen_string_literal: true | |
class ObjectNameDecorator < SimpleDelegator | |
delegate :class, :is_a?, to: :__getobj__ | |
def self.collection(objects) | |
objects.map { |group| ObjectNameDecorator.new(object) } | |
end | |
private | |
def h | |
ActionController::Base.helpers | |
end | |
def url | |
Rails.application.routes.url_helpers | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment