Module: Tatty::DB::Attributes

Instance Method Summary collapse

Instance Method Details

#db_attr(name, default: nil, readonly: false) ⇒ Object



9
10
11
12
13
# File 'lib/tatty/db.rb', line 9

def db_attr(name, default: nil, readonly: false)
  name = name.to_sym
  define_method(name) { DB.get(name, default) }
  define_method("#{name}=".to_sym) { |val| DB.set(name => val) } unless readonly
end