Class: Croods::Model
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Croods::Model
- Defined in:
- lib/croods/model.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.resource ⇒ Object
11 12 13 |
# File 'lib/croods/model.rb', line 11 def self.resource "#{resource_name}::Resource".constantize end |
.resource_name ⇒ Object
7 8 9 |
# File 'lib/croods/model.rb', line 7 def self.resource_name to_s.pluralize end |
Instance Method Details
#as_json(_options = {}) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/croods/model.rb', line 15 def as_json( = {}) attributes = {} resource.response_attributes.each do |name, attribute| value = send(name) value = value.iso8601 if value && attribute.type == :datetime attributes[name] = value end attributes end |
#resource ⇒ Object
37 38 39 |
# File 'lib/croods/model.rb', line 37 def resource "#{resource_name}::Resource".constantize end |
#resource_name ⇒ Object
33 34 35 |
# File 'lib/croods/model.rb', line 33 def resource_name self.class.to_s.pluralize end |
#tenant ⇒ Object
27 28 29 30 31 |
# File 'lib/croods/model.rb', line 27 def tenant return unless Croods.multi_tenancy? public_send(Croods.multi_tenancy_by) end |