Class: Preloadable::PreloadableAttributeConfig
- Inherits:
-
Object
- Object
- Preloadable::PreloadableAttributeConfig
- Defined in:
- lib/jsonapi-preloadable.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#attrs ⇒ Object
9 10 11 |
# File 'lib/jsonapi-preloadable.rb', line 9 def attrs @attrs ||= {} end |
#defaults ⇒ Object
13 14 15 |
# File 'lib/jsonapi-preloadable.rb', line 13 def defaults @defaults ||= Set.new end |
Instance Method Details
#add(*args) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/jsonapi-preloadable.rb', line 17 def add(*args) if args.size == 1 # plain declaration # config.add relationship: :nested = args.first attrs[.keys.first] = else # aliased declaration # config.add :alias, relationship: :nested key, value = args attrs[key] = value end end |
#preload(*keys) ⇒ Object
31 32 33 34 |
# File 'lib/jsonapi-preloadable.rb', line 31 def preload(*keys) keys = [keys] if keys.instance_of?(Symbol) defaults.merge(keys) end |