lib/ecoportal/api/internal/preferences.rb in ecoportal-api-0.1.5 vs lib/ecoportal/api/internal/preferences.rb in ecoportal-api-0.1.6

- old
+ new

@@ -1,9 +1,26 @@ module Ecoportal module API class Internal class Preferences < Common::BaseModel - passthrough :show_sidebar, :show_shortcuts, :show_coming_soon, :show_recently_visited_forms, :show_tasks, to: :doc + [ + :show_sidebar, + :show_shortcuts, + :show_coming_soon, + :show_recently_visited_forms, + :show_tasks + ].each do |field| + define_method(field) do + if doc.key?(field) + doc[field] + else + true + end + end + define_method("#{field}=") do |value| + doc[field] = !!value + end + end end end end end