Module: SettingAccessors::Integration
- Defined in:
- lib/setting_accessors/integration.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(base) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 |
# File 'lib/setting_accessors/integration.rb', line 2 def self.included(base) base.validates_with SettingAccessors::IntegrationValidator #After the main record was saved, we can save its settings. #This is necessary as the record might have been a new record #without an ID yet base.after_save do settings.send(:persist!) end base.extend ClassMethods end |
Instance Method Details
#as_json(*args) ⇒ Object
82 83 84 85 86 87 88 |
# File 'lib/setting_accessors/integration.rb', line 82 def as_json(*args) json = super(*args) SettingAccessors::Internal.setting_accessor_names(self.class).each do |setting_name| json[setting_name.to_s] = send(setting_name) end json end |
#settings ⇒ Object
90 91 92 |
# File 'lib/setting_accessors/integration.rb', line 90 def settings @settings_accessor ||= SettingAccessors::Accessor.new(self) end |