Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
This is simple decorator for Ruby.
Kumadori mean make-up for Japanese Kabuki.
Add this line to your application's Gemfile:
gem 'kumadori'
And then execute:
$ bundle
Or install it yourself as:
$ gem install kumadori
Kumadori decorate your instance by #{instance.class}Decorator class.
#
# Basic ruby class.
#
class User
attr_accesstor :first_name, :last_name
def initialize(first_name, last_name)
self.first_name = first_name
self.last_name = last_name
end
end
#
# Decorator class for User instance.
#
class UserDecorator < Kumadori::BaseDecorator
def full_name
"#{self.last_name} #{self.first_name}"
end
end
user = User.new('Yuji', 'Arakaki')
# user instance decorated by UserDecorator
decorated_user = Kumadori.decorate(user)
decorated_user.full_name # => "Arakaki Yuji"
if you not defined #{instance.class}Decorator class, it's instance decorated by Kumadori::BaseDecorator. So, if you want defined method for every instance, you just override Kumadori::BaseDecorator, and defined method.
class Animal
end
module Kumadori
class BaseDecorator < ::SimpleDelegator
def live?
true
end
end
end
animal = Animal.new
# Because of AnimalDecorator class is not defiend,
# it is decorated by Kumadori::BaseDecorator
decorated_animal = Kumadori.decorate(animal)
decorated_animal.live? # => true
if you want to decorate all items in collection, use Kumadori.collection_decorate method.
members = []
members << User.new('Kanoko', 'Higa')
members << User.new('Ai', 'Kawasaki')
members << User.new('Takeo', 'Kikuchi')
decorated_members = Kumadori.collection_decorate(members)
decorated_members.map{ |user| user.full_name} # => ["Higa Kanoko", "Kawasaki Ai", "Kikuchi Takeo"]
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)FAQs
Unknown package
We found that kumadori demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.