Module: ActiveModel::Serializable
- Included in:
- ArraySerializer, DefaultSerializer, Serializer
- Defined in:
- lib/active_model/serializable.rb,
lib/active_model/serializable/utils.rb
Defined Under Namespace
Modules: Utils
Class Method Summary collapse
Instance Method Summary collapse
- #as_json(options = {}) ⇒ Object
- #embedded_in_root_associations ⇒ Object
- #namespace ⇒ Object
- #serializable_data ⇒ Object
- #serializable_object_with_notification(options = {}) ⇒ Object
Class Method Details
.included(base) ⇒ Object
5 6 7 |
# File 'lib/active_model/serializable.rb', line 5 def self.included(base) base.extend Utils end |
Instance Method Details
#as_json(options = {}) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/active_model/serializable.rb', line 9 def as_json(={}) instrument('!serialize') do if root = .fetch(:root, json_key) hash = { root => serializable_object() } hash.merge!(serializable_data) hash else serializable_object() end end end |
#embedded_in_root_associations ⇒ Object
39 40 41 |
# File 'lib/active_model/serializable.rb', line 39 def {} end |
#namespace ⇒ Object
35 36 37 |
# File 'lib/active_model/serializable.rb', line 35 def namespace get_namespace && Utils._const_get(get_namespace) end |
#serializable_data ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/active_model/serializable.rb', line 27 def serializable_data .tap do |hash| if respond_to?(:meta) && hash[] = end end end |
#serializable_object_with_notification(options = {}) ⇒ Object
21 22 23 24 25 |
# File 'lib/active_model/serializable.rb', line 21 def serializable_object_with_notification(={}) instrument('!serialize') do serializable_object() end end |