Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

decorate-responder

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

decorate-responder

  • 2.1.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Decorate::Responder Build Status

A Rails responder that will apply a decorator to a resource in the responder chain.

Installation

Add this line to your application's Gemfile:

gem 'decorate-responder'

And then execute:

$ bundle

Or install it yourself as:

$ gem install decorate-responder

You will also need a decorator gem like draper or your own decorator implementation.

Usage

Add Responders::DecorateResponder to your responder chain:

class AppResponder < Responder
  include Responders::DecorateResponder
end

class MyController < ApplicationController
  self.responder = AppResponder
end

Or use it with plataformatec/responders:

class MyController < ApplicationController
  responders Responders::DecorateResponder
end

If you're using a decorator gem such as draper that injects a decorate method into your resources they will get decorated automatically.

When using draper, you may want to pass a context hash from the controller to the decorator. You can provide this context by adding a (public!) decoration_context method to the controller:

class AppController
  responders Responder::DecorateResponder
  
  def decoration_context
    { color: false }
  end
end

If you want to build even more advanced decoration logic, you can also explicitly decorate your resources by adding a decorate method to your controller:

class AppController
  responders Responders::DecorateResponder

  def decorate(resource)
  	MyDecorator.new resource
  end
end

If the resource and controller do not have a decorate method the resource will not be decorated.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Add tests for your feature.
  4. Add your feature.
  5. Commit your changes (git commit -am 'Add some feature')
  6. Push to the branch (git push origin my-new-feature)
  7. Create new Pull Request

License

MIT License

Copyright (c) 2013, Jan Graichen

FAQs

Package last updated on 23 Oct 2019

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc