lib/billogram/resource.rb in billogram-0.6.5 vs lib/billogram/resource.rb in billogram-0.6.6
- old
+ new
@@ -1,7 +1,9 @@
-require "active_support/core_ext/string/inflections.rb"
+# frozen_string_literal: true
+require 'active_support/core_ext/string/inflections'
+
module Billogram
class Resource
class << self
def relations
@relations ||= []
@@ -13,11 +15,11 @@
end
def build_objects(data)
case data
when Hash then new(data)
- when Array then data.map{|item| build_objects(item) }
+ when Array then data.map { |item| build_objects(item) }
else data
end
end
end
@@ -36,21 +38,20 @@
def to_json(*args)
to_hash.to_json(*args)
end
def to_hash
- instance_variables
- .each_with_object({}) do |variable, obj|
- value = instance_variable_get(variable)
+ instance_variables.each_with_object({}) do |variable, obj|
+ value = instance_variable_get(variable)
- case value
- when Resource
- value = value.to_hash
- when Array
- value = value.map(&:to_hash)
- end
-
- obj[variable[1..-1]] = value
+ case value
+ when Resource
+ value = value.to_hash
+ when Array
+ value = value.map(&:to_hash)
end
+
+ obj[variable[1..-1]] = value
+ end
end
end
end