Class: SelfControl::StepBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/self-control/step_builder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(actor, options) ⇒ StepBuilder

Returns a new instance of StepBuilder.



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/self-control/step_builder.rb', line 5

def initialize(actor, options)
  @actor = actor
  @actions = [*options.delete(:should)].flatten.compact.uniq.map(&:to_sym)
  @default = options.delete(:action) || (@actions.size == 1 ? @actions.first : nil)
  @name = (options.delete(:to) || @actions.join('_or_')).to_sym
  
  @if = options.delete(:if)
  @unless = options.delete(:unless)
  
  @doable = !!(@if || @unless)
  
  @meta = options
end

Instance Attribute Details

#actionsObject

Returns the value of attribute actions.



3
4
5
# File 'lib/self-control/step_builder.rb', line 3

def actions
  @actions
end

#actorObject

Returns the value of attribute actor.



3
4
5
# File 'lib/self-control/step_builder.rb', line 3

def actor
  @actor
end

#defaultObject

Returns the value of attribute default.



3
4
5
# File 'lib/self-control/step_builder.rb', line 3

def default
  @default
end

#ifObject

Returns the value of attribute if.



3
4
5
# File 'lib/self-control/step_builder.rb', line 3

def if
  @if
end

#metaObject

Returns the value of attribute meta.



3
4
5
# File 'lib/self-control/step_builder.rb', line 3

def meta
  @meta
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/self-control/step_builder.rb', line 3

def name
  @name
end

#unlessObject

Returns the value of attribute unless.



3
4
5
# File 'lib/self-control/step_builder.rb', line 3

def unless
  @unless
end

Instance Method Details

#doable?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/self-control/step_builder.rb', line 19

def doable?
  @doable
end