Socket
Book a DemoInstallSign in
Socket

no_integrity

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

no_integrity

0.6.0
bundlerRubygems
Version published
Maintainers
1
Created
Source

NoIntegrity

What is This?

Simple hash serialization with loose type coercion. Built for ActiveRecord models, but does not rely specifically on anything from Rails.

How do I use it?

For starters, throw this in your Gemfile:

gem "no_integrity"

Then, add this to your class:

class MrArbitrary < ActiveRecord::Base
  include NoIntegrity

  attr_accessor :some_random_hash

  no_attribute :misc
  no_attribute :hair, type: 'String'
  no_attribute :age, type: 'Integer'
  no_attribute :height, type: 'String'
  no_attribute :eyes, type: 'String'
  no_attribute :friendly, type: 'Boolean', default: true
  no_attribute :cheese
  no_attribute :ham
  no_attribute :balogne
end

Finally, you can make calls like this:

arbs = MrArbitrary.new
arbs.friendly? # => false
arbs.friendly = true
arbs.friendly? # => true

You can define as many attributes as you want, and you can specify any of the following coercion types:

  • String
  • Integer
  • Boolean

Upgrading From 0.4.0

For 0.5.0 I added the ability to store default values for each of the attributes. This required some changes to the way that attributes were setup and stored for each object.

In your classes you'll need to convert from:

no_attribute hair: 'String'

To:

no_attribute :hair, type: 'String'

Also if you relied on any of the undocumented method calls, you'll need to update them so they can handle the new internal structure.

Why?

A while back, I needed serialized attributes but it either didn't work for my use case or it wasn't made yet. So, I wrote this gem.

Contributing

Do not modify the gemspec or version unless you absolutely need to!

  • 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 01 Aug 2016

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.