Class: PolicyMachineStorageAdapter::ActiveRecord::PolicyElement
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- PolicyMachineStorageAdapter::ActiveRecord::PolicyElement
show all
- Defined in:
- lib/policy_machine_storage_adapters/active_record.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args, &block) ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/policy_machine_storage_adapters/active_record.rb', line 31
def method_missing(meth, *args, &block)
if respond_to?(meth)
send(meth, *args)
elsif meth.to_s[-1] == '='
@extra_attributes_hash[meth.to_s] = args.first
else
super
end
end
|
Instance Attribute Details
Returns the value of attribute extra_attributes_hash.
28
29
30
|
# File 'lib/policy_machine_storage_adapters/active_record.rb', line 28
def
@extra_attributes_hash
end
|
Instance Method Details
48
49
50
51
52
53
54
55
56
57
58
|
# File 'lib/policy_machine_storage_adapters/active_record.rb', line 48
def
@extra_attributes_hash = JSON.parse(self., quirks_mode: true) if self.
@extra_attributes_hash ||= {}
@extra_attributes_hash.(*self.class.column_names).each do |key, value|
send("#{key}=", value) unless value.nil?
end
@extra_attributes_hash.each do |key, value|
define_singleton_method key, lambda {@extra_attributes_hash[key.to_s]}
define_singleton_method "#{key}=", lambda { | value | @extra_attributes_hash[key.to_s] = value }
end
end
|
#respond_to_missing?(meth, *args) ⇒ Boolean
43
44
45
46
|
# File 'lib/policy_machine_storage_adapters/active_record.rb', line 43
def respond_to_missing?(meth, *args)
unless @extra_attributes_hash
@extra_attributes_hash[meth.to_s] || super
end
|
60
61
62
63
|
# File 'lib/policy_machine_storage_adapters/active_record.rb', line 60
def
unless @extra_attributes_hash
self. = .to_json
end
|