module ThreeScaleToolbox::Entities::Entity
Constants
- PRINTABLE_VARS
- VERBOSE_PRINTABLE_VARS
Attributes
attrs[R]
id[R]
remote[R]
verbose[RW]
Public Class Methods
new(id:, remote:, attrs: nil, verbose: false)
click to toggle source
# File lib/3scale_toolbox/entities/base_entity.rb, line 18 def initialize(id:, remote:, attrs: nil, verbose: false) @id = id.to_i @remote = remote @attrs = attrs @verbose = verbose end
Public Instance Methods
to_s()
click to toggle source
# File lib/3scale_toolbox/entities/base_entity.rb, line 25 def to_s if @verbose format_vars(printable_attrs: self.class.const_get(:VERBOSE_PRINTABLE_VARS, inherit: true)) else format_vars(printable_attrs: self.class.const_get(:PRINTABLE_VARS, inherit: true)) end end
Private Instance Methods
format_vars(printable_attrs: nil)
click to toggle source
# File lib/3scale_toolbox/entities/base_entity.rb, line 35 def format_vars(printable_attrs: nil) print_attrs = attrs.merge({ ":id" => @id }) formatted_vars = printable_attrs.map do |attr| "#{attr} => #{attrs[attr]}" end formatted_vars.join("\n") end