Class: ActiveModelSerializers::SerializationContext
- Inherits:
-
Object
- Object
- ActiveModelSerializers::SerializationContext
- Defined in:
- lib/active_model_serializers/serialization_context.rb
Defined Under Namespace
Modules: UrlHelpers
Class Attribute Summary collapse
Instance Attribute Summary collapse
-
#key_transform ⇒ Object
readonly
Returns the value of attribute key_transform.
-
#query_parameters ⇒ Object
readonly
Returns the value of attribute query_parameters.
-
#request_url ⇒ Object
readonly
Returns the value of attribute request_url.
Instance Method Summary collapse
-
#initialize(*args) ⇒ SerializationContext
constructor
A new instance of SerializationContext.
Constructor Details
#initialize(*args) ⇒ SerializationContext
Returns a new instance of SerializationContext.
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/active_model_serializers/serialization_context.rb', line 28 def initialize(*args) = args. if args.size == 1 request = args.pop [:request_url] = request.original_url[/\A[^?]+/] [:query_parameters] = request.query_parameters end @request_url = .delete(:request_url) @query_parameters = .delete(:query_parameters) @url_helpers = .delete(:url_helpers) || self.class.url_helpers @default_url_options = .delete(:default_url_options) || self.class. end |
Class Attribute Details
.default_url_options ⇒ Object
12 13 14 |
# File 'lib/active_model_serializers/serialization_context.rb', line 12 def @default_url_options ||= {} end |
.url_helpers ⇒ Object
8 9 10 |
# File 'lib/active_model_serializers/serialization_context.rb', line 8 def url_helpers @url_helpers ||= Module.new end |
Instance Attribute Details
#key_transform ⇒ Object (readonly)
Returns the value of attribute key_transform.
26 27 28 |
# File 'lib/active_model_serializers/serialization_context.rb', line 26 def key_transform @key_transform end |
#query_parameters ⇒ Object (readonly)
Returns the value of attribute query_parameters.
26 27 28 |
# File 'lib/active_model_serializers/serialization_context.rb', line 26 def query_parameters @query_parameters end |
#request_url ⇒ Object (readonly)
Returns the value of attribute request_url.
26 27 28 |
# File 'lib/active_model_serializers/serialization_context.rb', line 26 def request_url @request_url end |