class RubyLLM::Browser::Rails::ApprovalRecord
Durable row for a host-issued single-use {RubyLLM::Browser::Approval}.
Only {ActiveRecordApprovalStore#consume_once} mutates a consumed approval, and it does so inside a row-locked transaction so two workers cannot both consume the same grant.
Public Class Methods
dump_action(action)
click to toggle source
# File lib/ruby_llm/browser/rails/approval_record.rb, line 33 def self.dump_action(action) return nil if action.nil? Redactor.canonical_json(action) end
load_action(value)
click to toggle source
# File lib/ruby_llm/browser/rails/approval_record.rb, line 27 def self.load_action(value) return nil if value.nil? value.is_a?(String) ? JSON.parse(value) : value end
to_time(value)
click to toggle source
# File lib/ruby_llm/browser/rails/approval_record.rb, line 39 def self.to_time(value) case value when nil then nil when Time then value else value.respond_to?(:to_time) ? value.to_time : value end end
Public Instance Methods
to_approval()
click to toggle source
# File lib/ruby_llm/browser/rails/approval_record.rb, line 17 def to_approval Approval.new( id: id, actor_id: actor_id, run_id: run_id, url: url, action_digest: action_digest, action: self.class.load_action(action), page_revision: page_revision, operation_id: operation_id, session_id: session_id, issued_at: self.class.to_time(issued_at), expires_at: self.class.to_time(expires_at), consumed_at: self.class.to_time(consumed_at), revoked: revoked ) end