module OptionsModel::Concerns::Serialization

Public Instance Methods

to_h() click to toggle source
# File lib/options_model/concerns/serialization.rb, line 8
def to_h
  hash = {}

  hash.merge! unused_attributes if self.class.with_unused_attributes?
  self.class.attribute_names_for_inlining.each do |name|
    hash[name] = send(name)
  end
  self.class.attribute_names_for_nesting.each do |name|
    hash[name] = send(name).to_h
  end

  hash
end