Class: Population::Populate

Inherits:
Object
  • Object
show all
Defined in:
lib/population/populate.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, &block) ⇒ Populate

Returns a new instance of Populate.



5
6
7
8
9
# File 'lib/population/populate.rb', line 5

def initialize(name, &block)
  @name = name
  @klass = name.to_s.classify.constantize
  @block = block
end

Instance Attribute Details

#blockObject (readonly)

Returns the value of attribute block.



3
4
5
# File 'lib/population/populate.rb', line 3

def block
  @block
end

#klassObject (readonly)

Returns the value of attribute klass.



3
4
5
# File 'lib/population/populate.rb', line 3

def klass
  @klass
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/population/populate.rb', line 3

def name
  @name
end

Instance Method Details

#downObject



15
16
17
# File 'lib/population/populate.rb', line 15

def down
  Population::Database.reset_table_belonging_to(klass)
end

#upObject



11
12
13
# File 'lib/population/populate.rb', line 11

def up
  @klass.instance_eval(&block)
end