Sha256: 43d7cb4fdf10be3fa8d928b7f19acbbcb015150417bf0f3ed1519d750d4cb515

Contents?: true

Size: 794 Bytes

Versions: 8

Compression:

Stored size: 794 Bytes

Contents

require 'pp'
require 'pathname'
require 'rubygems'
require 'adapter/memory'

root_path = Pathname(__FILE__).dirname.join('..').expand_path
lib_path  = root_path.join('lib')
$:.unshift(lib_path)
require 'toystore'

class User
  include Toy::Store
  store :memory, {}

  attribute :email, String
  attribute :my_really_long_field_name, String, :abbr => :my
end

user = User.create({
  :email => 'nunemaker@gmail.com',
  :my_really_long_field_name => 'something',
})

pp Marshal.load(User.store.client[user.id])
# Abbreviated attributes are stored in the database as the abbreviation for when you want to conserve space. The abbreviation and the full attribute name work exactly the same in Ruby, the only difference is how they get persisted.
# {"my"=>"something", "email"=>"nunemaker@gmail.com"}

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
toystore-0.8.3 examples/attributes_abbreviation.rb
toystore-0.8.2 examples/attributes_abbreviation.rb
toystore-0.8.1 examples/attributes_abbreviation.rb
toystore-0.8.0 examples/attributes_abbreviation.rb
toystore-0.7.0 examples/attributes_abbreviation.rb
toystore-0.6.6 examples/attributes_abbreviation.rb
toystore-0.6.5 examples/attributes_abbreviation.rb
toystore-0.6.4 examples/attributes_abbreviation.rb