Class: Hanami::Model::Mapping Private
- Inherits:
-
Object
- Object
- Hanami::Model::Mapping
- Extended by:
- Transproc::Registry
- Defined in:
- lib/hanami/model/mapping.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Mapping
Instance Method Summary collapse
- #attribute(name, options) ⇒ Object private
-
#initialize(&blk) ⇒ Mapping
constructor
private
A new instance of Mapping.
- #model(entity) ⇒ Object private
- #process(input) ⇒ Object private
- #register_as(name) ⇒ Object private
- #reverse? ⇒ Boolean private
- #t(name, *args) ⇒ Object private
- #translate(attribute) ⇒ Object private
Constructor Details
#initialize(&blk) ⇒ Mapping
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.
Returns a new instance of Mapping.
18 19 20 21 22 23 |
# File 'lib/hanami/model/mapping.rb', line 18 def initialize(&blk) @attributes = {} @r_attributes = {} instance_eval(&blk) @processor = @attributes.empty? ? ::Hash : t(:rename_keys, @attributes) end |
Instance Method Details
#attribute(name, options) ⇒ 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.
39 40 41 42 43 44 |
# File 'lib/hanami/model/mapping.rb', line 39 def attribute(name, ) from = .fetch(:from, name) @attributes[name] = from @r_attributes[from] = name end |
#model(entity) ⇒ 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.
31 32 |
# File 'lib/hanami/model/mapping.rb', line 31 def model(entity) end |
#process(input) ⇒ 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.
47 48 49 |
# File 'lib/hanami/model/mapping.rb', line 47 def process(input) @processor[input] end |
#register_as(name) ⇒ 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.
35 36 |
# File 'lib/hanami/model/mapping.rb', line 35 def register_as(name) end |
#reverse? ⇒ Boolean
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.
52 53 54 |
# File 'lib/hanami/model/mapping.rb', line 52 def reverse? @r_attributes.any? end |
#t(name, *args) ⇒ 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.
26 27 28 |
# File 'lib/hanami/model/mapping.rb', line 26 def t(name, *args) self.class[name, *args] end |
#translate(attribute) ⇒ 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.
57 58 59 |
# File 'lib/hanami/model/mapping.rb', line 57 def translate(attribute) @r_attributes.fetch(attribute) end |