Skip to content
This repository has been archived by the owner on Feb 6, 2018. It is now read-only.

nhurden/spira-timestamps

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

spira-timestamps Build Status Gem Version

Add automatic timestamps to your Spira models.

spira-timestamps adds created and updated DateTime attributes to your model with the Dublin Core created and modified predicates.

Installation

Add this line to your application's Gemfile:

gem 'spira-timestamps'

And then execute:

$ bundle

Or install it yourself as:

$ gem install spira-timestamps

Usage

To add timestamps to a model, just add include Spira::Timestamps to your model class.

For example:

class Person < Spira::Base
  include Spira::Timestamps

  property :name, predicate: FOAF.name, type: String
end

Timestamps are updated automatically when you save your model.

You can access the timestamps either as DateTime objects via the created_at and updated_at properties or as Date objects via the created_on and updated_on properties. For example:

> bob = Person.new(name: 'Bob').save
=> <Person:2170778720 @subject: _:g2170778680> 
> bob.created_at
=> #<DateTime: 2014-12-08T20:48:27+11:00 ...>
> bob.created_on
=> #<Date: 2014-12-08 ...>
> bob.touch
=> <Person:2170778720 @subject: _:g2170778680> 
> bob.updated_at
=> #<DateTime: 2014-12-08T20:49:41+11:00 ...>
> bob.updated_on
=> #<Date: 2014-12-08 ...>

Contributing

  1. Fork it ( https://github.com/nhurden/spira-timestamps/fork )
  2. Create your feature branch (git checkout -b feature/my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin feature/my-new-feature)
  5. Create a new Pull Request

About

A Spira plugin for automatic timestamps.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages