Skip to content

Commit

Permalink
Extracted generic Resource methods into a module
Browse files Browse the repository at this point in the history
  • Loading branch information
Narnach committed Oct 13, 2009
1 parent a6922d9 commit 7e83c75
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
1 change: 1 addition & 0 deletions lib/rubyists.rb
Expand Up @@ -2,5 +2,6 @@
require 'dm-validations'
require 'dm-aggregates'

require 'rubyists/resource'
require 'rubyists/user'
require 'rubyists/country'
9 changes: 1 addition & 8 deletions lib/rubyists/country.rb
@@ -1,5 +1,6 @@
class Country
include DataMapper::Resource
extend Rubyists::Resource

has 1, :user

Expand All @@ -20,13 +21,5 @@ def populate
country.save
end
end

def destroy_all
all.each {|model| model.destroy}
end

def none?
count == 0
end
end
end
11 changes: 11 additions & 0 deletions lib/rubyists/resource.rb
@@ -0,0 +1,11 @@
module Rubyists
module Resource
def destroy_all
all.each {|model| model.destroy}
end

def none?
count == 0
end
end
end
6 changes: 6 additions & 0 deletions spec/rubyists/resource_spec.rb
@@ -0,0 +1,6 @@
require File.join(File.dirname(__FILE__), %w[.. spec_helper])
require 'rubyists/resource'

describe Rubyists::Resource do
it 'should be tested'
end

0 comments on commit 7e83c75

Please sign in to comment.