Module: ThreeScaleToolbox::Entities::Entity

Included in:
Account
Defined in:
lib/3scale_toolbox/entities/base_entity.rb

Constant Summary collapse

PRINTABLE_VARS =
%w[
  id
].freeze
VERBOSE_PRINTABLE_VARS =
%w[
  id
].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#attrsObject (readonly)

Returns the value of attribute attrs.



16
17
18
# File 'lib/3scale_toolbox/entities/base_entity.rb', line 16

def attrs
  @attrs
end

#idObject (readonly)

Returns the value of attribute id.



16
17
18
# File 'lib/3scale_toolbox/entities/base_entity.rb', line 16

def id
  @id
end

#remoteObject (readonly)

Returns the value of attribute remote.



16
17
18
# File 'lib/3scale_toolbox/entities/base_entity.rb', line 16

def remote
  @remote
end

#verboseObject

Returns the value of attribute verbose.



15
16
17
# File 'lib/3scale_toolbox/entities/base_entity.rb', line 15

def verbose
  @verbose
end

Instance Method Details

#initialize(id:, remote:, attrs: nil, verbose: false) ⇒ Object



18
19
20
21
22
23
# 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

#to_sObject



25
26
27
28
29
30
31
# 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