Module: AbilityHost::TimeBoundedHelpers

Defined in:
app/models/components/ability_host.rb

Instance Method Summary collapse

Instance Method Details

#already_started_hashHash (protected)

Returns a condition which will return started rows(start_at before current time) when ORed together in a database query. Reverse-merge this with your conditions to obtain the set of already started rows in the table.

Returns:

  • (Hash)

    The hash condition.


109
110
111
112
113
# File 'app/models/components/ability_host.rb', line 109

def already_started_hash
  {
    start_at: (Time.min..Time.zone.now)
  }
end

#currently_valid_hashesArray<Hash> (protected)

Returns an array of conditions which will return currently valid rows when ORed together in a database query. Reverse-merge each of these hashes with your conditions to obtain the set of currently valid rows in the table.

Returns:

  • (Array<Hash>)

    An array of hash conditions indicating the currently valid rows.


91
92
93
94
95
96
97
98
99
100
101
102
# File 'app/models/components/ability_host.rb', line 91

def currently_valid_hashes
  [
    {
      start_at: (Time.min..Time.zone.now),
      end_at: nil
    },
    {
      start_at: (Time.min..Time.zone.now),
      end_at: (Time.zone.now..Time.max)
    }
  ]
end