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

qoobaa-enum_field

Package Overview
Dependencies
Maintainers
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

qoobaa-enum_field

  • 0.1.1
  • Rubygems
  • Socket score

Version published
Maintainers
3
Created
Source

= EnumField

Macro to emulate a MySQL enum_field type thing - fork of giraffesoft/enum_field. It might be used instead of STI in some cases.

== Usage

This plugin encapsulates a validates_inclusion_of and automatically gives you a few more goodies automatically. That's it!

class Computer < ActiveRecord:Base
  extend EnumField
  enum_field :status, ['on', 'off', 'standby', 'sleep', 'out of this world']

  # Optionally with a message to replace the default one
  # enum_field :status, ['on', 'off', 'standby', 'sleep', 'out of this world'], :message => "incorrect status"

  #...
end

This will give you a few things:

  • add a validates_inclusion_of with a simple error message ("invalid #{field}") or your custom message
  • define the following query methods, in the name of expressive code:
    • on?
    • off?
    • standby?
    • sleep?
    • out_of_this_world?
  • define the STATUSES constant, which contains the acceptable values

= License

Copyright (c) 2008 James Golick, released under the MIT license

FAQs

Package last updated on 10 Aug 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

  • 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