Class: Rake::Migrations::Task

Inherits:
Object
  • Object
show all
Defined in:
lib/rake/migrations/task.rb

Constant Summary collapse

RUN_ONCE =
:once
RUN_EVERY_TIME =
:every

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, attrs = {}) ⇒ Task

Returns a new instance of Task.



8
9
10
11
12
# File 'lib/rake/migrations/task.rb', line 8

def initialize(name, attrs = {})
  @name      = name
  @command   = attrs[:command]
  @frequency = attrs[:frequency] || RUN_ONCE
end

Instance Attribute Details

#commandObject (readonly)

Returns the value of attribute command.



6
7
8
# File 'lib/rake/migrations/task.rb', line 6

def command
  @command
end

#frequencyObject (readonly)

Returns the value of attribute frequency.



6
7
8
# File 'lib/rake/migrations/task.rb', line 6

def frequency
  @frequency
end

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/rake/migrations/task.rb', line 6

def name
  @name
end

Instance Method Details

#==(other) ⇒ Object Also known as: equal?



31
32
33
# File 'lib/rake/migrations/task.rb', line 31

def ==(other)
  name == other.name
end

#run_every_time?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/rake/migrations/task.rb', line 14

def run_every_time?
  frequency == RUN_EVERY_TIME
end

#run_once?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/rake/migrations/task.rb', line 18

def run_once?
  frequency == RUN_ONCE
end

#to_hObject



22
23
24
25
26
27
28
29
# File 'lib/rake/migrations/task.rb', line 22

def to_h
  {
    name => {
      command: command,
      frequency: frequency
    }
  }
end