Class: Readme::Payload
- Inherits:
-
Object
- Object
- Readme::Payload
- Defined in:
- lib/readme/payload.rb
Instance Attribute Summary collapse
-
#ignore ⇒ Object
readonly
Returns the value of attribute ignore.
Instance Method Summary collapse
-
#initialize(har, info, ip_address, development:) ⇒ Payload
constructor
A new instance of Payload.
- #to_json(*_args) ⇒ Object
Constructor Details
#initialize(har, info, ip_address, development:) ⇒ Payload
Returns a new instance of Payload.
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/readme/payload.rb', line 15 def initialize(har, info, ip_address, development:) @har = har @user_info = info.slice(:id, :label, :email) @user_info[:id] = info[:api_key] unless info[:api_key].nil? # swap api_key for id if api_key is present @user_info[:id] = Readme::Mask.mask(@user_info[:id]) @log_id = info[:log_id] @ignore = info[:ignore] @ip_address = ip_address @development = development @uuid = SecureRandom.uuid end |
Instance Attribute Details
#ignore ⇒ Object (readonly)
Returns the value of attribute ignore.
13 14 15 |
# File 'lib/readme/payload.rb', line 13 def ignore @ignore end |
Instance Method Details
#to_json(*_args) ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/readme/payload.rb', line 27 def to_json(*_args) { _id: validate_uuid(@log_id) ? @log_id : @uuid, _version: 3, group: @user_info, clientIPAddress: @ip_address, development: @development, request: JSON.parse(@har.to_json) }.to_json end |