Module: Consul::Power::DynamicAccess::InstanceMethods
- Included in:
- Consul::Power
- Defined in:
- lib/consul/power/dynamic_access.rb
Instance Method Summary collapse
- #for_model(*args) ⇒ Object
- #for_record(*args) ⇒ Object
- #include!(power_name, *args) ⇒ Object
- #include?(power_name, *args) ⇒ Boolean
- #include_model!(*args) ⇒ Object
- #include_model?(*args) ⇒ Boolean
- #include_object!(power_name, *context_and_object) ⇒ Object
- #include_object?(power_name, *context_and_object) ⇒ Boolean
- #include_power!(power_name, *context) ⇒ Object
- #include_power?(power_name, *context) ⇒ Boolean
- #include_record!(*args) ⇒ Object
- #include_record?(*args) ⇒ Boolean
- #name_for_model(*args) ⇒ Object
- #name_for_record(*args) ⇒ Object
Instance Method Details
#for_model(*args) ⇒ Object
63 64 65 |
# File 'lib/consul/power/dynamic_access.rb', line 63 def for_model(*args) send(name_for_model(*args)) end |
#for_record(*args) ⇒ Object
43 44 45 |
# File 'lib/consul/power/dynamic_access.rb', line 43 def for_record(*args) send(name_for_record(*args)) end |
#include!(power_name, *args) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/consul/power/dynamic_access.rb', line 16 def include!(power_name, *args) warn "makandra/consul: #include! is deprececated. Use #include_power! and #include_object! instead." if args.size == 0 include_power!(power_name, *args) else include_object!(power_name, *args) end end |
#include?(power_name, *args) ⇒ Boolean
7 8 9 10 11 12 13 14 |
# File 'lib/consul/power/dynamic_access.rb', line 7 def include?(power_name, *args) warn "makandra/consul: #include? is deprececated. Use #include_power? and #include_object? instead." if args.size == 0 include_power?(power_name, *args) else include_object?(power_name, *args) end end |
#include_model!(*args) ⇒ Object
71 72 73 |
# File 'lib/consul/power/dynamic_access.rb', line 71 def include_model!(*args) include_power!(name_for_model(*args)) end |
#include_model?(*args) ⇒ Boolean
67 68 69 |
# File 'lib/consul/power/dynamic_access.rb', line 67 def include_model?(*args) include_power?(name_for_model(*args)) end |
#include_object!(power_name, *context_and_object) ⇒ Object
38 39 40 41 |
# File 'lib/consul/power/dynamic_access.rb', line 38 def include_object!(power_name, *context_and_object) power_name = power_name.to_s send("#{singularize_power_name(power_name)}!", *context_and_object) end |
#include_object?(power_name, *context_and_object) ⇒ Boolean
33 34 35 36 |
# File 'lib/consul/power/dynamic_access.rb', line 33 def include_object?(power_name, *context_and_object) power_name = power_name.to_s send("#{singularize_power_name(power_name)}?", *context_and_object) end |
#include_power!(power_name, *context) ⇒ Object
29 30 31 |
# File 'lib/consul/power/dynamic_access.rb', line 29 def include_power!(power_name, *context) send("#{power_name}!", *context) end |
#include_power?(power_name, *context) ⇒ Boolean
25 26 27 |
# File 'lib/consul/power/dynamic_access.rb', line 25 def include_power?(power_name, *context) send("#{power_name}?", *context) end |
#include_record!(*args) ⇒ Object
52 53 54 55 |
# File 'lib/consul/power/dynamic_access.rb', line 52 def include_record!(*args) adjective, record = Util.adjective_and_argument(*args) include_object!(name_for_record(*args), record) end |
#include_record?(*args) ⇒ Boolean
47 48 49 50 |
# File 'lib/consul/power/dynamic_access.rb', line 47 def include_record?(*args) adjective, record = Util.adjective_and_argument(*args) include_object?(name_for_record(*args), record) end |
#name_for_model(*args) ⇒ Object
57 58 59 60 61 |
# File 'lib/consul/power/dynamic_access.rb', line 57 def name_for_model(*args) adjective, model_class = Util.adjective_and_argument(*args) collection_name = model_class.name.underscore.gsub('/', '_').pluralize [adjective, collection_name].select(&:present?).join('_') end |
#name_for_record(*args) ⇒ Object
75 76 77 78 |
# File 'lib/consul/power/dynamic_access.rb', line 75 def name_for_record(*args) adjective, record = Util.adjective_and_argument(*args) name_for_model(adjective, record.class) end |