Class: ActiveModelSerializers::Test::Serializer::AssertSerializer
- Inherits:
-
Object
- Object
- ActiveModelSerializers::Test::Serializer::AssertSerializer
- Defined in:
- lib/active_model_serializers/test/serializer.rb
Instance Attribute Summary (collapse)
-
- (Object) expectation
Returns the value of attribute expectation.
-
- (Object) message
Returns the value of attribute message.
-
- (Object) response
Returns the value of attribute response.
-
- (Object) serializers
readonly
Returns the value of attribute serializers.
Instance Method Summary (collapse)
-
- (AssertSerializer) initialize
constructor
A new instance of AssertSerializer.
- - (Boolean) matches?
- - (Object) subscribe
- - (Object) unsubscribe
Constructor Details
- (AssertSerializer) initialize
Returns a new instance of AssertSerializer
43 44 45 46 |
# File 'lib/active_model_serializers/test/serializer.rb', line 43 def initialize @serializers = Set.new @_subscribers = [] end |
Instance Attribute Details
- (Object) expectation
Returns the value of attribute expectation
41 42 43 |
# File 'lib/active_model_serializers/test/serializer.rb', line 41 def expectation @expectation end |
- (Object) message
Returns the value of attribute message
40 41 42 |
# File 'lib/active_model_serializers/test/serializer.rb', line 40 def @message end |
- (Object) response
Returns the value of attribute response
41 42 43 |
# File 'lib/active_model_serializers/test/serializer.rb', line 41 def response @response end |
- (Object) serializers (readonly)
Returns the value of attribute serializers
40 41 42 |
# File 'lib/active_model_serializers/test/serializer.rb', line 40 def serializers @serializers end |
Instance Method Details
- (Boolean) matches?
52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/active_model_serializers/test/serializer.rb', line 52 def matches? # Force body to be read in case the template is being streamed. response.body case expectation when a_serializer? then matches_class? when Symbol then matches_symbol? when String then matches_string? when Regexp then matches_regexp? when NilClass then matches_nil? else fail ArgumentError, 'assert_serializer only accepts a String, Symbol, Regexp, ActiveModel::Serializer, or nil' end end |
- (Object) subscribe
66 67 68 69 70 71 |
# File 'lib/active_model_serializers/test/serializer.rb', line 66 def subscribe @_subscribers << ActiveSupport::Notifications.subscribe(event_name) do |_name, _start, _finish, _id, payload| serializer = payload[:serializer].name serializers << serializer end end |
- (Object) unsubscribe
73 74 75 76 77 |
# File 'lib/active_model_serializers/test/serializer.rb', line 73 def unsubscribe @_subscribers.each do |subscriber| ActiveSupport::Notifications.unsubscribe(subscriber) end end |