Skip to content

Instantly share code, notes, and snippets.

@lujanfernaud
Created July 26, 2018 08:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lujanfernaud/96d53a294ac2cf44a46d14b1228dc476 to your computer and use it in GitHub Desktop.
Save lujanfernaud/96d53a294ac2cf44a46d14b1228dc476 to your computer and use it in GitHub Desktop.
Rails: Simple Decorator
# 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