Class: Resourcey::ControllerSerialization::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/resourcey/controller_serialization.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



9
10
11
12
# File 'lib/resourcey/controller_serialization.rb', line 9

def initialize
  @actions_serializers = Hash.new.with_indifferent_access
  @fallback_serializer = nil
end

Instance Attribute Details

#actions_serializersObject (readonly)

Returns the value of attribute actions_serializers.



6
7
8
# File 'lib/resourcey/controller_serialization.rb', line 6

def actions_serializers
  @actions_serializers
end

#fallback_serializerObject

Returns the value of attribute fallback_serializer.



7
8
9
# File 'lib/resourcey/controller_serialization.rb', line 7

def fallback_serializer
  @fallback_serializer
end

Instance Method Details

#action(action_name, opts = {}) ⇒ Object



14
15
16
# File 'lib/resourcey/controller_serialization.rb', line 14

def action(action_name, opts = {})
  @actions_serializers[action_name] = opts[:serializer]
end

#default(opts = {}) ⇒ Object



18
19
20
# File 'lib/resourcey/controller_serialization.rb', line 18

def default(opts = {})
  @fallback_serializer = opts[:serializer]
end

#get_serializer_for_action(action_name) ⇒ Object



22
23
24
# File 'lib/resourcey/controller_serialization.rb', line 22

def get_serializer_for_action(action_name)
  actions_serializers[action_name] || fallback_serializer
end