Class: ReleaseFeature::Feature

Inherits:
Object
  • Object
show all
Defined in:
lib/release_feature/feature.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, environment:, open_at:, close_at:) ⇒ Feature

Returns a new instance of Feature.

Parameters:

  • name (String, Symbol)
  • environment (String, Symbol)
  • open_at (Time)
  • close_at (Time)

Raises:



11
12
13
14
15
16
17
18
# File 'lib/release_feature/feature.rb', line 11

def initialize(name:, environment:, open_at:, close_at:)
  validate_present({ name: name, environment: environment, open_at: open_at, close_at: close_at })
  @name = cast_to_sym(:name, name)
  @environment = cast_to_sym(:environment, environment)
  @open_at = open_at
  @close_at = close_at
  raise ReleaseFeature::Error, errors_full_message unless valid?
end

Instance Attribute Details

#close_atObject (readonly)

Returns the value of attribute close_at.



5
6
7
# File 'lib/release_feature/feature.rb', line 5

def close_at
  @close_at
end

#environmentObject (readonly)

Returns the value of attribute environment.



5
6
7
# File 'lib/release_feature/feature.rb', line 5

def environment
  @environment
end

#errorsObject (readonly)

Returns the value of attribute errors.



5
6
7
# File 'lib/release_feature/feature.rb', line 5

def errors
  @errors
end

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/release_feature/feature.rb', line 5

def name
  @name
end

#open_atObject (readonly)

Returns the value of attribute open_at.



5
6
7
# File 'lib/release_feature/feature.rb', line 5

def open_at
  @open_at
end

Instance Method Details

#permitted?(current_time) ⇒ TrueClass, FalseClass

Parameters:

  • current_time (Time)

Returns:

  • (TrueClass, FalseClass)


22
23
24
# File 'lib/release_feature/feature.rb', line 22

def permitted?(current_time)
  (open_at...close_at).cover?(current_time)
end