class Widget
Widget
model conatining widget craeate and update attributes
Attributes
description[RW]
kind[RW]
name[RW]
Public Class Methods
get_payload(widget)
click to toggle source
Gets Json represenatation of widget object
@param [Object] widget Widget
object
@return [Json] Json represenatation of widget object
# File lib/domain/widget.rb, line 51 def self.get_payload(widget) widget.as_json.to_json end
new(name: nil, description: nil, kind: nil)
click to toggle source
Inialise the widget model
@param [String] name Name of widget @param [String] description @param [String] kind Kind of widget - hidden/visible
# File lib/domain/widget.rb, line 18 def initialize(name: nil, description: nil, kind: nil) self.name = name self.description = description self.kind = kind end
Public Instance Methods
as_json(options = {})
click to toggle source
Converts Widget
object to Hash and deletes null value fields
@param [Refrence] options
@return [Hash] Hash of widget object
# File lib/domain/widget.rb, line 31 def as_json(options = {}) hash_data = { self.class.name.downcase => { name: @name, description: @description, kind: @kind } } hash_data.each { |k, v| v.delete_if { |k, v| v.nil? || v.empty? } } hash_data end