Sha256: 5bb0f8d6e7bd1f3920d10bfad157c285c71cda255c50899dfc7dd4c6f1159d2e

Contents?: true

Size: 630 Bytes

Versions: 5

Compression:

Stored size: 630 Bytes

Contents

require 'sequel'

DB = Sequel("sqlite:///#{__DIR__}/../blog.db")

class Entry < Sequel::Model(:entry)
  set_schema do
    primary_key :id

    time :created
    time :updated
    text :title
    text :content
  end

  def self.add(title, content)
    create :title => title, :content => content,
      :created => Time.now, :updated => Time.now
  end

  def update(title = title, content = content)
    self.title, self.content, self.updated = title, content, Time.now
    save
  end
end

Entry.create_table! unless Entry.table_exists?

if Entry.empty?
  Entry.add 'Blog created', 'Exciting news today, this blog was created'
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
clivecrous-ramaze-0.3.9.5 examples/blog/model/entry.rb
ramaze-0.3.0 examples/blog/src/model.rb
ramaze-0.3.5 examples/blog/src/model.rb
ramaze-0.3.9 examples/blog/model/entry.rb
ramaze-0.3.9.1 examples/blog/model/entry.rb