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

decent_decoration

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

decent_decoration

  • 0.1.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

decent_decoration

Build Status Code Climate Coverage Status Gem Version

decent_decoration allows you to use excellent decent_exposure 3.0 gem with decorators.

Installation

Add this line to your application's Gemfile:

gem 'decent_decoration', '~> 0.1.0'

And then execute:

$ bundle

Usage

# app/controllers/conferences_controller.rb
# with decent_exposure
class ConferencesController < ApplicationController
  expose(:conference) { ConferenceDecorator.new(build_conference) }

  private

  def build_conference
    # create new conference or fetch existing one
  end
end

# with decent_decoration
class ConferencesController < ApplicationController
  expose_decorated(:conference)
end

decent_decoration makes decorated objects accessible in views. They remain undecorated in your controllers.

Define a decorator explicitly:

# app/controllers/conferences_controller.rb
class ConferencesController < ApplicationController
  expose_decorated(:conference, decorator: SponsoredConferenceDecorator)
end

decent_decoration detect automatically if you want to decorate a collection. To circumvent this pass collection: true/false

# app/controllers/conferences_controller.rb
class ConferencesController < ApplicationController
  expose_decorated(:conferences, collection: false)
end

decent_decoration supports most of the awesome decent_exposure api. Read more about it!

# app/controllers/attendees_controller.rb
class AttendeesController < ApplicationController
  expose_decorated(:conference)
  expose_decorated(:attendees, scope: :conference)
end

You can use any decorator mechanism as long as ConferenceDecorator responds to #decorate or #new. Try draper.

Contributing

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

Copyright © 2012–2014 netguru. See LICENSE for further details.

FAQs

Package last updated on 24 Aug 2016

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