Skip to content

Commit

Permalink
Fix keyword arguments for representers and 'with_options'
Browse files Browse the repository at this point in the history
  • Loading branch information
mayorova committed Sep 18, 2024
1 parent a897958 commit f34f392
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion app/representers/cms/layout_representer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module CMS::LayoutRepresenter
property :system_name
property :liquid_enabled

with_options(if: ->(user_options:, **) { !user_options&.dig(:short) }) do
with_options(if: ->(options) { !options[:user_options]&.dig(:short) }) do
property :draft, render_nil: true
property :published, render_nil: true
end
Expand Down
2 changes: 1 addition & 1 deletion app/representers/cms/page_representer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module CMS::PageRepresenter
p.property :hidden, getter: ->(*) { hidden? }
end

with_options(if: ->(user_options:, **) { !user_options&.dig(:short) }) do
with_options(if: ->(options) { !options[:user_options]&.dig(:short) }) do
property :draft, render_nil: true
property :published, render_nil: true
end
Expand Down
2 changes: 1 addition & 1 deletion app/representers/cms/partial_representer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module CMS::PartialRepresenter
property :updated_at
property :system_name

with_options(if: ->(user_options:, **) { !user_options&.dig(:short) }) do
with_options(if: ->(options) { !options[:user_options]&.dig(:short) }) do
property :draft, render_nil: true
property :published, render_nil: true
end
Expand Down
2 changes: 1 addition & 1 deletion app/representers/cms/portlet_representer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module CMS::PortletRepresenter
property :portlet_type
property :name

with_options(if: ->(user_options:, **) { !user_options&.dig(:short) }) do
with_options(if: ->(options) { !options[:user_options]&.dig(:short) }) do
property :draft, render_nil: true
property :published, render_nil: true
end
Expand Down
12 changes: 6 additions & 6 deletions app/representers/member_permissions_representer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ class MemberPermissionsRepresenter < ThreeScale::Representer

wraps_resource :permissions

property :user_id, getter: ->(user_options:, **) { user_options[:user].id }
property :role, getter: ->(user_options:, **) { user_options[:user].role }
property :user_id, getter: ->(options) { options[:user_options]&.[](:user)&.id }
property :role, getter: ->(options) { options[:user_options]&.[](:user)&.role }

class JSON < MemberPermissionsRepresenter
include Roar::JSON

# NOTE: The list of allowed sections is sorted to facilitate acceptance testing, this is not part of the API specification
property :allowed_sections, getter: ->(user_options:, **) { user_options[:user].allowed_sections&.sort }
property :allowed_service_ids, getter: ->(user_options:, **) { user_options[:user].allowed_service_ids }, render_nil: true
property :allowed_sections, getter: ->(options) { options[:user_options]&.[](:user)&.allowed_sections&.sort }
property :allowed_service_ids, getter: ->(options) { options[:user_options]&.[](:user)&.allowed_service_ids }, render_nil: true

link :user do |opts|
user = opts[:user]
Expand All @@ -59,8 +59,8 @@ class XML < MemberPermissionsRepresenter
wraps_resource :permissions

# NOTE: The list of allowed sections is sorted to facilitate acceptance testing, this is not part of the API specification
collection :allowed_sections, as: :allowed_section, wrap: :allowed_sections, getter: ->(user_options:, **) { user_options[:user].allowed_sections&.sort }
collection :allowed_service_ids, as: :allowed_service_id, wrap: :allowed_service_ids, getter: ->(user_options:, **) { user_options[:user].allowed_service_ids }
collection :allowed_sections, as: :allowed_section, wrap: :allowed_sections, getter: ->(options) { options[:user_options]&.[](:user)&.allowed_sections&.sort }
collection :allowed_service_ids, as: :allowed_service_id, wrap: :allowed_service_ids, getter: ->(options) { options[:user_options]&.[](:user)&.allowed_service_ids }
end

end

0 comments on commit f34f392

Please sign in to comment.