Module: Consul::Power::ClassMethods
Instance Attribute Summary collapse
Instance Method Summary
collapse
#for_model, #for_record, #include_model!, #include_model?, #include_record!, #include_record?
Instance Attribute Details
#current ⇒ Object
Returns the value of attribute current.
79
80
81
|
# File 'lib/consul/power.rb', line 79
def current
@current
end
|
Instance Method Details
#context_count_name(name) ⇒ Object
71
72
73
|
# File 'lib/consul/power.rb', line 71
def context_count_name(name)
"#{name}_context_count"
end
|
#power(*names, &block) ⇒ Object
65
66
67
68
69
|
# File 'lib/consul/power.rb', line 65
def power(*names, &block)
names.each do |name|
define_power(name, &block)
end
end
|
#power_ids_name(name) ⇒ Object
75
76
77
|
# File 'lib/consul/power.rb', line 75
def power_ids_name(name)
"#{name.to_s.singularize}_ids"
end
|
#with_power(inner_power, &block) ⇒ Object
81
82
83
84
85
86
87
88
89
90
|
# File 'lib/consul/power.rb', line 81
def with_power(inner_power, &block)
unless inner_power.is_a?(self)
inner_power = new(inner_power)
end
old_power = current
self.current = inner_power
block.call
ensure
self.current = old_power
end
|