Skip to content
This repository has been archived by the owner on Jan 27, 2019. It is now read-only.

Properties

Victor Rodrigues edited this page Aug 27, 2013 · 1 revision

By default, a property is a String.

class User < Hari::Node
  property :name
end

user = User.create(name: 'John')
user.name
=> 'John'

user = User.create(name: 1)
user.name
=> '1'

Properties also accepts a type option:

class User < Hari::Node
  property :active,      type: Boolean
  property :age,         type: Integer
  property :score,       type: Float
  property :preferences, type: Hash
  property :roles,       type: Array
  property :birthday,    type: Date
end

class Mail < Hari::Node
  property :sent_at, type: DateTime
end

class Log < Hari::Node
  property :sent_at, type: Time
end
Clone this wiki locally