Class: Grape::Roar::Extensions::Relations::Mapper
- Inherits:
-
Object
- Object
- Grape::Roar::Extensions::Relations::Mapper
- Extended by:
- Forwardable
- Defined in:
- lib/grape/roar/extensions/relations/mapper.rb
Instance Method Summary collapse
- #adapter ⇒ Object
- #decorate(klass) ⇒ Object
-
#initialize(entity) ⇒ Mapper
constructor
A new instance of Mapper.
Constructor Details
#initialize(entity) ⇒ Mapper
Returns a new instance of Mapper.
10 11 12 13 |
# File 'lib/grape/roar/extensions/relations/mapper.rb', line 10 def initialize(entity) @entity = entity @config = {} end |
Instance Method Details
#adapter ⇒ Object
15 16 17 |
# File 'lib/grape/roar/extensions/relations/mapper.rb', line 15 def adapter @adapter ||= Adapters.for(model_klass) end |
#decorate(klass) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/grape/roar/extensions/relations/mapper.rb', line 19 def decorate(klass) @model_klass = klass config.each_pair do |relation, opts| representer_for(relation.to_s, opts) unless opts.key(:extend) map_relation(relation, opts) end end |