module Apps::Common::Schema::Concerns::PotentialAction

Public Instance Methods

action() click to toggle source

Handles the case when there is one action

# File lib/apps/common/schema/concerns/potential_action.rb, line 7
def action
  actions.first if actions.size == 1
end
actions() click to toggle source
# File lib/apps/common/schema/concerns/potential_action.rb, line 11
def actions
  @actions ||= [@action].compact
end
serialize() click to toggle source
Calls superclass method
# File lib/apps/common/schema/concerns/potential_action.rb, line 15
def serialize
  if actions.any?
    super.merge("potentialAction" => serialize_actions)
  else
    super
  end
end
serialize_actions() click to toggle source
# File lib/apps/common/schema/concerns/potential_action.rb, line 23
def serialize_actions
  # Gmail uses a hash for one action and an array for multiple.
  # Outlook uses an array regardless and breaks if it's a hash.
  # So we will always return an array.
  
  # action&.serialize || actions.map(&:serialize)
  actions.map(&:serialize)
end