module DocumentSerializable
Constants
- VERSION
Public Instance Methods
attribute(name, type = String, options = {})
click to toggle source
# File lib/document_serializable.rb, line 42 def attribute(name, type = String, options = {}) property_class.send :attribute, name, type, options delegate name, to: :property_object delegate "#{name}=".to_sym, to: :property_object end
attributes()
click to toggle source
Calls superclass method
# File lib/document_serializable.rb, line 10 def attributes property_object.attributes.merge(super) end
property_class()
click to toggle source
# File lib/document_serializable.rb, line 36 def property_class @property_class ||= begin Class.new(superclass.try(:property_class) || Object) { include Virtus.model(nullify_blank: true) } end end
property_object()
click to toggle source
# File lib/document_serializable.rb, line 22 def property_object @property_object ||= begin properties = self.properties properties = JSON.parse(properties) if properties.is_a? String self.class.property_class.new(properties || {}) end end
reload(options = nil)
click to toggle source
Calls superclass method
# File lib/document_serializable.rb, line 14 def reload(options = nil) super @property_object = nil self end