Class: ForemanPatch::Ticket::Payload
- Inherits:
-
Object
- Object
- ForemanPatch::Ticket::Payload
- Defined in:
- app/services/foreman_patch/ticket/payload.rb
Instance Attribute Summary collapse
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
-
#window ⇒ Object
readonly
Returns the value of attribute window.
Instance Method Summary collapse
- #[](key) ⇒ Object
-
#initialize(window) ⇒ Payload
constructor
A new instance of Payload.
- #keys ⇒ Object
- #to_json(*args) ⇒ Object
Constructor Details
#initialize(window) ⇒ Payload
Returns a new instance of Payload.
7 8 9 10 11 12 13 14 15 16 17 |
# File 'app/services/foreman_patch/ticket/payload.rb', line 7 def initialize(window) @window = window @safe_render = FieldRender.new(window) @raw = {} TicketField.all.each do |key| @raw.update(key.key => calculate_value(key)) end end |
Instance Attribute Details
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
5 6 7 |
# File 'app/services/foreman_patch/ticket/payload.rb', line 5 def raw @raw end |
#window ⇒ Object (readonly)
Returns the value of attribute window.
5 6 7 |
# File 'app/services/foreman_patch/ticket/payload.rb', line 5 def window @window end |
Instance Method Details
#[](key) ⇒ Object
23 24 25 |
# File 'app/services/foreman_patch/ticket/payload.rb', line 23 def [](key) @raw[key] end |
#keys ⇒ Object
19 20 21 |
# File 'app/services/foreman_patch/ticket/payload.rb', line 19 def keys TicketField.all.pluck(:key) end |
#to_json(*args) ⇒ Object
27 28 29 |
# File 'app/services/foreman_patch/ticket/payload.rb', line 27 def to_json(*args) @raw.compact.to_json(*args) end |