Class: Apps::Adapters::Gmail::Markup::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/apps/adapters/gmail/markup/base.rb

Instance Method Summary collapse

Constructor Details

#initialize(**attrs) ⇒ Base

Returns a new instance of Base.



8
9
10
# File 'lib/apps/adapters/gmail/markup/base.rb', line 8

def initialize(**attrs)
  attrs.each { |attr, value| instance_variable_set(:"@#{attr}", value) }
end

Instance Method Details

#as_jsonObject



16
17
18
# File 'lib/apps/adapters/gmail/markup/base.rb', line 16

def as_json
  { "@type" => type }
end

#to_json(pretty: false) ⇒ Object



20
21
22
# File 'lib/apps/adapters/gmail/markup/base.rb', line 20

def to_json(pretty: false)
  pretty ? JSON.pretty_generate(as_json) : JSON.dump(as_json)
end

#typeObject



12
13
14
# File 'lib/apps/adapters/gmail/markup/base.rb', line 12

def type
  @type ||= self.class.name.split('::')[-1]
end