You're Invited: Meet the Socket team at BSidesSF and RSAC - April 27 - May 1.RSVP
Socket
Sign inDemoInstall
Socket

rails_engine_decorators

Package Overview
Dependencies
Maintainers
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rails_engine_decorators

1.0.0
Rubygems
Version published
Maintainers
4
Created
Source

= Rails Engine Decorators

Extend Rails Engine's business logic (models, controllers, helpers, etc.) easily from your application or other engine.

This solution was first implemented in the Forem engine, see https://github.com/radar/forem/pull/260

== Authors

== Usage

(From Forem's patch):

Standard practice for including such changes in your application or extension is to create a file within the relevant app/models or app/controllers directory with the original class name with _decorator appended.

Adding a custom method to the Post model:

# app/decorators/models/forem/post_decorator.rb

Forem::Post.class_eval do
  def some_method
    ...
  end
end

Adding a custom method to the PostsController:

# app/decorators/controllers/forem/posts_controller_decorator.rb

Forem::PostsController.class_eval do
  def some_action
    ...
  end
end

The exact same format can be used to redefine an existing method.

FAQs

Package last updated on 22 Jul 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts