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.
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/active_model_serializers/serialization_context.rb', line 26 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
10 11 12 |
# File 'lib/active_model_serializers/serialization_context.rb', line 10 def @default_url_options ||= {} end |
.url_helpers ⇒ Object
6 7 8 |
# File 'lib/active_model_serializers/serialization_context.rb', line 6 def url_helpers @url_helpers ||= Module.new end |
Instance Attribute Details
#key_transform ⇒ Object (readonly)
Returns the value of attribute key_transform.
24 25 26 |
# File 'lib/active_model_serializers/serialization_context.rb', line 24 def key_transform @key_transform end |
#query_parameters ⇒ Object (readonly)
Returns the value of attribute query_parameters.
24 25 26 |
# File 'lib/active_model_serializers/serialization_context.rb', line 24 def query_parameters @query_parameters end |
#request_url ⇒ Object (readonly)
Returns the value of attribute request_url.
24 25 26 |
# File 'lib/active_model_serializers/serialization_context.rb', line 24 def request_url @request_url end |