Skip to content

Commit

Permalink
add versions helper;
Browse files Browse the repository at this point in the history
  • Loading branch information
alexkravets committed Jun 18, 2015
1 parent 07713a6 commit a847998
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ants.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ Collection of concerns and helpers for Rails + Mongoid + Character web developme
s.add_dependency('mongoid-slug', '>= 4.0.0')

s.add_development_dependency('rails', [ '>= 4.1' ])
s.add_development_dependency('rake', [ '>= 0.8.7' ])
s.add_development_dependency('rspec', [ '>= 2.0' ])
s.add_development_dependency('rspec-aspic', [ '>= 0.0.2' ])
s.add_development_dependency 'bundler'
s.add_development_dependency 'coveralls'

s.add_development_dependency 'bundler', '~> 1.9'
s.add_development_dependency 'rake', '~> 10.0'

end
1 change: 1 addition & 0 deletions lib/ants.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ module Ants
require "concerns/ants/slug"
require "concerns/ants/publication"
require "concerns/ants/sorted_relations"
require "concerns/ants/versions"
end
2 changes: 1 addition & 1 deletion lib/ants/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Ants
VERSION = "0.1.1"
VERSION = "0.1.2"
end
25 changes: 25 additions & 0 deletions lib/concerns/ants/versions.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module Ants
module Versions
extend ActiveSupport::Concern

included do

# returns list of available object versions, requires
# include Mongoid::History::Trackable to be configured
def _document_versions
hash = {}

history_tracks.only(:created_at, :version).collect do |h|
hash[h.version] = "Version #{ h.version }#{ h.created_at }"
end

if hash.empty?
hash = { '' => '--' }
end

return hash
end

end
end
end

0 comments on commit a847998

Please sign in to comment.