Class: Population::Populate
- Inherits:
-
Object
- Object
- Population::Populate
- Defined in:
- lib/population/populate.rb
Instance Attribute Summary collapse
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#klass ⇒ Object
readonly
Returns the value of attribute klass.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #down ⇒ Object
-
#initialize(name, &block) ⇒ Populate
constructor
A new instance of Populate.
- #up ⇒ Object
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
#block ⇒ Object (readonly)
Returns the value of attribute block.
3 4 5 |
# File 'lib/population/populate.rb', line 3 def block @block end |
#klass ⇒ Object (readonly)
Returns the value of attribute klass.
3 4 5 |
# File 'lib/population/populate.rb', line 3 def klass @klass end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/population/populate.rb', line 3 def name @name end |
Instance Method Details
#down ⇒ Object
15 16 17 |
# File 'lib/population/populate.rb', line 15 def down Population::Database.reset_table_belonging_to(klass) end |
#up ⇒ Object
11 12 13 |
# File 'lib/population/populate.rb', line 11 def up @klass.instance_eval(&block) end |