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.
16 17 18 19 20 21 |
# File 'lib/hanami/model/mapping.rb', line 16 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.
37 38 39 40 41 42 |
# File 'lib/hanami/model/mapping.rb', line 37 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.
29 30 |
# File 'lib/hanami/model/mapping.rb', line 29 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.
45 46 47 |
# File 'lib/hanami/model/mapping.rb', line 45 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.
33 34 |
# File 'lib/hanami/model/mapping.rb', line 33 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.
50 51 52 |
# File 'lib/hanami/model/mapping.rb', line 50 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.
24 25 26 |
# File 'lib/hanami/model/mapping.rb', line 24 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.
55 56 57 |
# File 'lib/hanami/model/mapping.rb', line 55 def translate(attribute) @r_attributes.fetch(attribute) end |