Class: Virtus::AttributeSet

Inherits:
Object
  • Object
show all
Defined in:
lib/skala.rb

Overview

patch Virtus to not serialize unset lazy attributes

Instance Method Summary collapse

Instance Method Details

#get(object) ⇒ Object



31
32
33
34
35
36
37
38
39
# File 'lib/skala.rb', line 31

def get(object)
  each_with_object({}) do |attribute, attributes|
    name = attribute.name

    if attribute.public_reader? && (!attribute.lazy? || attribute.defined?(object))
      attributes[name] = object.__send__(name)
    end
  end
end