Last active
December 12, 2015 07:59
-
-
Save miketierney/4740904 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'storable' | |
require 'faker' | |
module ViewHelpers | |
# … | |
# Data Faking | |
class Subscriber < Storable | |
field :id => Integer | |
field :first_name | |
field :last_name | |
field :created_at | |
def full_name | |
"#{self.first_name} #{self.last_name}" | |
end | |
def self.all | |
ObjectSpace.each_object(self).to_a.sort{|a,b| a.id <=> b.id} | |
end | |
def self.bootstrap | |
fixtures = YAML.load ERB.new(File.read(file)).result | |
fixtures.each do |f| | |
from_hash(f[1]) # from_hash is provided by Storable | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment