module Norma43::Models::Mixins::AttributesAssignment

Constants

EMPTY_ATTRIBUTES

Public Instance Methods

attributes() click to toggle source
# File lib/norma43/models/mixins/attributes_assignment.rb, line 18
def attributes
  instance_variables.map { |ivar_name|
    attr_reader_method_name = ivar_name.to_s.delete_prefix("@").to_sym
    next unless public_methods(false).include?(attr_reader_method_name)

    attr_value = public_send(attr_reader_method_name)

    [attr_reader_method_name, attr_value]
  }.compact.to_h
end
Also aliased as: to_hash, to_h
attributes=(new_attributes) click to toggle source
# File lib/norma43/models/mixins/attributes_assignment.rb, line 9
def attributes=(new_attributes)
  Hash(new_attributes).each do |attr_name, attr_value|
    attr_writer_method_name = "#{attr_name}=".to_sym
    next unless public_methods(false).include?(attr_writer_method_name)

    public_send(attr_writer_method_name, attr_value)
  end
end
to_h()
Alias for: attributes
to_hash()
Alias for: attributes