-
Notifications
You must be signed in to change notification settings - Fork 0
Automagically store attributes ending with _ip as an integer in the DB
License
belt/ip_attribute
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
= IpAttribute Provides conventions for attributes of an AR instance ending w/_ip. String based _ip attributes will appear as either an IPv4 or an IPv6 string, but will be stored as an integer. == Example Table name: users id :integer(4) not null, primary key login :string(255) not null login_ip :decimal(10) default(2130706433), not null created_at :datetime updated_at :datetime Class: User class User < ActiveRecord::Base include IpAttribute end Yields: user = User.new user.login_ip = '127.0.0.1' # => 2130706433 user.login_ip = 'wuff' # => nil user.login_ip = 2130706433 # => 2130706433 user.login_ip # => #<IPAddr: IPv4:127.0.0.1/255.255.255.255> user.login_ip.to_s # => '127.0.0.1' user.login_ip.to_i # => 2130706433 Copyright (c) 2009 [Paul Belt], released under the MIT license
About
Automagically store attributes ending with _ip as an integer in the DB
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published