Module: Mitake::Model Private

Included in:
Balance, Message, Recipient
Defined in:
lib/mitake/model.rb,
lib/mitake/model/accessor.rb,
lib/mitake/model/attributes.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Provide attributes accessor

Since:

  • 0.1.0

Defined Under Namespace

Modules: Accessor, Attributes

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0



14
15
16
17
18
19
# File 'lib/mitake/model.rb', line 14

def self.included(base)
  base.class_eval do
    include Attributes
    extend Accessor
  end
end

Instance Method Details

#attributesHash

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Get attributes as hash

Returns:

  • (Hash)

    the object attributes

Since:

  • 0.1.0



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/mitake/model.rb', line 26

def attributes
  self
    .class
    .attribute_names
    .map { |attr| [attr, send(attr)] }
    .reject { |_, value| value.nil? }
    .map do |attr, value|
    [attr, value.respond_to?(:attributes) ? value.attributes : value]
  end
    .to_h
end