Class: Resourcey::ControllerSerialization::Configuration
- Inherits:
-
Object
- Object
- Resourcey::ControllerSerialization::Configuration
- Defined in:
- lib/resourcey/controller_serialization.rb
Instance Attribute Summary collapse
-
#actions_serializers ⇒ Object
readonly
Returns the value of attribute actions_serializers.
-
#fallback_serializer ⇒ Object
Returns the value of attribute fallback_serializer.
Instance Method Summary collapse
- #action(action_name, opts = {}) ⇒ Object
- #default(opts = {}) ⇒ Object
- #get_serializer_for_action(action_name) ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize ⇒ Configuration
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_serializers ⇒ Object (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_serializer ⇒ Object
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 |