Skip to content

diegodurs/checklist

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Checklist

Declare in you class what the instance should validate. This is essentially an admin tool for checkup or to known the current step of a wizard or a process.

Example

Declaration

class User
  include Checklist

  checklist do
    check "Facebook profile loaded" do
      facebook_profile.present?
    end
    check "Invites friends" do
      frients.invited.count >= 0
    end
  end
end

Usage

user = User.new
user.checklist.valid?

# return array of [message, boolean] without block
# return an array with block
user.checklist.map_checked do |msg, bool|
  [msg, bool]
end

# iterator with [message, boolean]
user.checklist.each_checked do |msg, bool|
  puts "#{msg} - #{bool}"
end
<table>
  <% user.checklist.each_checked do |message, checked| %>
  <tr>
    <td> <%= message %> </td>
    <td>
      <%= checked ? '<i class="icon icon-thumbs-up"/>' : '<i class="icon icon-thumbs-down"/>'%>
    </td>
  </tr>
</table>

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages