lib/ecoportal/api/internal/account.rb in ecoportal-api-0.1.5 vs lib/ecoportal/api/internal/account.rb in ecoportal-api-0.1.6
- old
+ new
@@ -10,22 +10,33 @@
def preset
self.permissions_preset.nil? ? "custom" : self.permissions_preset
end
+ def as_json
+ super.tap do |hash|
+ if preset == "custom"
+ hash["permissions_custom"] = permissions.as_json
+ else
+ hash.delete "permissions_custom"
+ end
+ hash["preferences"] = preferences.as_json
+ end
+ end
+
def permissions
return @permissions if defined?(@permissions)
- return @permissions = nil if doc["permissions_custom"].nil?
+ doc["permissions_custom"] ||= {}
@permissions = Internal::Permissions.new(doc["permissions_custom"])
end
def preferences
return @preferences if defined?(@preferences)
- return @preferences = nil if doc["preferences"].nil?
+ doc["preferences"] ||= {}
@preferences = Internal::Preferences.new(doc["preferences"])
end
end
end
end
end
require 'ecoportal/api/internal/permissions'
-require 'ecoportal/api/internal/preferences'
\ No newline at end of file
+require 'ecoportal/api/internal/preferences'