Module: Hipaapotamus
- Defined in:
- lib/hipaapotamus.rb,
lib/hipaapotamus/agent.rb,
lib/hipaapotamus/action.rb,
lib/hipaapotamus/policy.rb,
lib/hipaapotamus/version.rb,
lib/hipaapotamus/execution.rb,
lib/hipaapotamus/protected.rb,
lib/hipaapotamus/system_agent.rb,
lib/hipaapotamus/anonymous_agent.rb,
lib/hipaapotamus/record_callback_proxy.rb,
lib/hipaapotamus/accountability_context.rb,
lib/hipaapotamus/accountable_controller.rb,
lib/generators/hipaapotamus/install_generator.rb
Defined Under Namespace
Modules: AccountableController, Agent, Protected
Classes: AccountabilityContext, Action, AnonymousAgent, Execution, InstallGenerator, Policy, RecordCallbackProxy, SystemAgent
Constant Summary
collapse
- VERSION =
'0.2.0'
Class Method Summary
collapse
Class Method Details
.current_accountability_context ⇒ Object
33
34
35
|
# File 'lib/hipaapotamus.rb', line 33
def current_accountability_context
AccountabilityContext.current
end
|
.current_agent ⇒ Object
37
38
39
|
# File 'lib/hipaapotamus.rb', line 37
def current_agent
current_accountability_context.try(:agent)
end
|
.current_transaction ⇒ Object
25
26
27
|
# File 'lib/hipaapotamus.rb', line 25
def current_transaction
transaction_manager.current_transaction
end
|
.current_transaction_state ⇒ Object
29
30
31
|
# File 'lib/hipaapotamus.rb', line 29
def current_transaction_state
current_transaction.try(:state)
end
|
.root_transaction ⇒ Object
21
22
23
|
# File 'lib/hipaapotamus.rb', line 21
def root_transaction
transaction_manager.instance_exec { @stack.try(:first) } || current_transaction
end
|
.transaction_manager ⇒ Object
17
18
19
|
# File 'lib/hipaapotamus.rb', line 17
def transaction_manager
ActiveRecord::Base.connection.transaction_manager
end
|
.with_accountability(agent, &block) ⇒ Object
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/hipaapotamus.rb', line 41
def with_accountability(agent, &block)
execution = nil
accountability_context = AccountabilityContext.new(agent)
is_using_callbacks = root_transaction.joinable?
root_transaction.add_record RecordCallbackProxy.new accountability_context if is_using_callbacks
accountability_context.within do
execution = Execution.new(&block)
end
accountability_context.finalize! unless is_using_callbacks
execution.try(:value)
end
|
.without_accountability(&block) ⇒ Object
58
59
60
|
# File 'lib/hipaapotamus.rb', line 58
def without_accountability(&block)
with_accountability(AnonymousAgent.instance, &block)
end
|