Module: Mitake::Model Private
- 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
Defined Under Namespace
Modules: Accessor, Attributes
Class Method Summary collapse
- .included(base) ⇒ Object private
Instance Method Summary collapse
-
#attributes ⇒ Hash
private
Get attributes as hash.
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.
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
#attributes ⇒ Hash
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
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 |