Class: HelpScout::Base
- Inherits:
-
Object
- Object
- HelpScout::Base
- Defined in:
- lib/help_scout/base.rb
Direct Known Subclasses
Attachment, Conversation, Customer, Folder, Mailbox, Thread, User
Instance Method Summary collapse
- #as_json ⇒ Object
-
#to_h(method = :to_h) ⇒ Object
rubocop:disable Metrics/MethodLength.
- #to_json(*_args) ⇒ Object
Instance Method Details
#as_json ⇒ Object
29 30 31 32 33 |
# File 'lib/help_scout/base.rb', line 29 def as_json to_h(:as_json) do |result, attribute| result[HelpScout::Util.jsonify(attribute[:name])] = attribute[:value] end end |
#to_h(method = :to_h) ⇒ Object
rubocop:disable Metrics/MethodLength
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/help_scout/base.rb', line 13 def to_h(method = :to_h) # rubocop:disable Metrics/MethodLength {}.tap do |result| instance_variables.each do |var| attribute = { name: var, value: HelpScout::Util.serialized_value(instance_variable_get(var), method) } if block_given? yield(result, attribute) else result[keyify(attribute[:name])] = attribute[:value] end end end end |
#to_json(*_args) ⇒ Object
35 36 37 |
# File 'lib/help_scout/base.rb', line 35 def to_json(*_args) as_json.to_json end |