Module: InertiaRails::PropOnceable
- Included in:
- DeferProp, MergeProp, OnceProp, OptionalProp
- Defined in:
- lib/inertia_rails/prop_onceable.rb
Instance Attribute Summary collapse
-
#once_expires_in ⇒ Object
readonly
Returns the value of attribute once_expires_in.
-
#once_key ⇒ Object
readonly
Returns the value of attribute once_key.
Instance Method Summary collapse
Instance Attribute Details
#once_expires_in ⇒ Object (readonly)
Returns the value of attribute once_expires_in.
5 6 7 |
# File 'lib/inertia_rails/prop_onceable.rb', line 5 def once_expires_in @once_expires_in end |
#once_key ⇒ Object (readonly)
Returns the value of attribute once_key.
5 6 7 |
# File 'lib/inertia_rails/prop_onceable.rb', line 5 def once_key @once_key end |
Instance Method Details
#expires_at ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/inertia_rails/prop_onceable.rb', line 24 def expires_at return nil unless @once_expires_in = case @once_expires_in when ActiveSupport::Duration (Time.current + @once_expires_in).to_f when Numeric Time.current.to_f + @once_expires_in else raise ArgumentError, "Invalid `expires_in` value: #{@once_expires_in.inspect}" end ( * 1000).to_i end |
#fresh? ⇒ Boolean
20 21 22 |
# File 'lib/inertia_rails/prop_onceable.rb', line 20 def fresh? @fresh end |
#initialize(**props, &block) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/inertia_rails/prop_onceable.rb', line 7 def initialize(**props, &block) @once = props.fetch(:once, false) @once_key = props[:key] @once_expires_in = props[:expires_in] @fresh = props.fetch(:fresh, false) super end |
#once? ⇒ Boolean
16 17 18 |
# File 'lib/inertia_rails/prop_onceable.rb', line 16 def once? @once end |