Socket
Book a DemoInstallSign in
Socket

plastic_wrap

Package Overview
Dependencies
Maintainers
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

plastic_wrap

0.2.0
bundlerRubygems
Version published
Maintainers
2
Created
Source

PlasticWrap

A decorator.

Installation

Add this line to your application's Gemfile:

gem 'plastic_wrap'

And then execute:

$ bundle

Or install it yourself as:

$ gem install plastic_wrap

Usage

PlasticWrap is easy to use. There are 2 variants of wrapping.

The easiest and most maleable is Light. This uses SimpleDelegator under the covers to do all the heavy lifting.

class Leftovers
  def best_before
    @best_before ||= Time.now
  end
end

class ReadableBestBefore < PlasticWrap::Light
  def best_before
    super.strftime('%m-%y')
  end
end


ReadableBestBefore.wrap(Leftovers.new).best_before #=> 1-2001

The other variant is Heavy. This uses Delegator under the covers for its lifting. You may want to use this is you don't want to deal with tracing through method_missing calls.

class Leftovers
  def best_before
    @best_before ||= Time.now
  end
end

class ReadableBestBefore < PlasticWrap.create_wrap(Leftovers)
  def best_before
    super.strftime('%m-%y')
  end
end


ReadableBestBefore.wrap(Leftovers.new).best_before #=> 1-2001

No matter which variant you decide to use; the wrap method accepts Enumerables and will return an array of nicely wrapped models. You also get the benefit of all the built-in Rails helpers in your decorators.

Contributing

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

FAQs

Package last updated on 30 Nov 2014

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.