Class: FormDurations::CustomDuration
- Inherits:
-
Object
- Object
- FormDurations::CustomDuration
- Defined in:
- app/services/form_durations/custom_duration.rb
Overview
A class responsible for knowing about and returning the custom expiration duration
Instance Attribute Summary collapse
Class Method Summary collapse
-
.build(interval) ⇒ FormDurations::CustomDuration
Builds a FormDurations::CustomDuration instance from a given interval.
Instance Method Summary collapse
-
#initialize(interval) ⇒ CustomDuration
constructor
A new instance of CustomDuration.
-
#span ⇒ ActiveSupport::Duration
Gets the custom expiration duration.
Constructor Details
#initialize(interval) ⇒ CustomDuration
Returns a new instance of CustomDuration.
22 23 24 |
# File 'app/services/form_durations/custom_duration.rb', line 22 def initialize(interval) @interval = interval end |
Instance Attribute Details
#interval ⇒ Integer
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/services/form_durations/custom_duration.rb', line 9 class CustomDuration attr_reader :interval ## # Builds a FormDurations::CustomDuration instance from a given interval # # @param interval [Integer] the custom expiration number # @return [FormDurations::CustomDuration] an instance of this class # def self.build(interval) new(interval) end def initialize(interval) @interval = interval end ## # Gets the custom expiration duration # # @return [ActiveSupport::Duration] 60 days as the default value or interval days if specified # def span return 60.days if interval.zero? interval.days end end |
Class Method Details
.build(interval) ⇒ FormDurations::CustomDuration
Builds a FormDurations::CustomDuration instance from a given interval
18 19 20 |
# File 'app/services/form_durations/custom_duration.rb', line 18 def self.build(interval) new(interval) end |
Instance Method Details
#span ⇒ ActiveSupport::Duration
Gets the custom expiration duration
31 32 33 34 35 |
# File 'app/services/form_durations/custom_duration.rb', line 31 def span return 60.days if interval.zero? interval.days end |