class HelpScout::Base

Private Class Methods

base_path() click to toggle source
# File lib/help_scout/base.rb, line 8
def base_path
  name.split('::').last.downcase.pluralize
end

Public Instance Methods

as_json() click to toggle source
# 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) { |result, attribute| ... } click to toggle source
# 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) click to toggle source
# File lib/help_scout/base.rb, line 35
def to_json(*_args)
  as_json.to_json
end