Skip to content
/ splatter Public

Expand constructor arguments to instance variables base on `splat`.

License

Notifications You must be signed in to change notification settings

vroy/splatter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Splatter

Expand constructor arguments to instance variables base on splat.

This was inspired by Gourmet Service Objects, but to use without Virtus.

Usage

Splatter::Init

class AcceptInvite
  include Splatter::Init

  splat :invite, :user

  def call
    @invite.accept!(@user)
    UserMailer.invite_accepted(invite).deliver
  end
end

AcceptInvite.new(invite, user).call

Splatter::Service

class AcceptInvite
  include Splatter::Init
  include Splatter::Service

  splat :invite, :user

  def call
    @invite.accept!(@user)
    UserMailer.invite_accepted(invite).deliver
  end
end

AcceptInvite.call(invite, user)

Splatter

Use include Splatter to include both, Splatter::Init and Splatter::Service

Installation

Add this line to your application's Gemfile:

gem 'splatter'

And then execute:

$ bundle

Or install it yourself as:

$ gem install splatter

Contributing

  1. Fork it ( https://github.com/vroy/splatter/fork )
  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 a new Pull Request

About

Expand constructor arguments to instance variables base on `splat`.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages