Module: Reeve::Audit::Query::Scopes
- Included in:
- Entry, Reeve::Audit::Query
- Defined in:
- lib/reeve/audit/query.rb
Overview
Defined once and used from two places: on Query, all opens on the whole ledger;
on Entry (and on a relation being chained), all is the current scope, which is
what makes these compose in any order.
Instance Method Summary collapse
- #allowed ⇒ Object
-
#between(from, to) ⇒ Object
By occurred_at: the ledger is ordered by when the call happened, not by when the row landed.
- #denied ⇒ Object
- #for_agent(agent_id) ⇒ Object
- #for_principal(principal) ⇒ Object
- #for_tool(tool_name) ⇒ Object
Instance Method Details
#allowed ⇒ Object
34 35 36 |
# File 'lib/reeve/audit/query.rb', line 34 def allowed all.where(outcome: Entry::ALLOW) end |
#between(from, to) ⇒ Object
By occurred_at: the ledger is ordered by when the call happened, not by when the row landed.
44 45 46 |
# File 'lib/reeve/audit/query.rb', line 44 def between(from, to) all.where(occurred_at: from..to) end |
#denied ⇒ Object
38 39 40 |
# File 'lib/reeve/audit/query.rb', line 38 def denied all.where(outcome: Entry::DENY) end |
#for_agent(agent_id) ⇒ Object
26 27 28 |
# File 'lib/reeve/audit/query.rb', line 26 def for_agent(agent_id) all.where(agent_id: agent_id.to_s) end |
#for_principal(principal) ⇒ Object
22 23 24 |
# File 'lib/reeve/audit/query.rb', line 22 def for_principal(principal) all.where(Query.principal_key(principal)) end |
#for_tool(tool_name) ⇒ Object
30 31 32 |
# File 'lib/reeve/audit/query.rb', line 30 def for_tool(tool_name) all.where(tool_name: tool_name.to_s) end |