Sha256: a89f1eac97894be41c08a23e42d2c4d005d6ea99a27d861adab5a31344f0bc91

Contents?: true

Size: 854 Bytes

Versions: 1

Compression:

Stored size: 854 Bytes

Contents

module Commands::Activities::Activity
  class Create < RestPack::Service::Commands::SingleCreate
    required do
      integer :application_id
      integer :user_id
      string  :content
    end

    optional do
      string  :title, empty: true
      string  :tags, empty: true
      string  :access, empty: true
      float   :latitude
      float   :longitude
      model   :data, class: Hash
    end

    def init
      if latitude.present? || longitude.present?
        if latitude.present? != longitude.present?
          service_error "Both Latitude and Longitude are required"
        end
      end

      #TEMP: GJ: some example service errors
      if title == "error"
        service_error "This is a service error"
      end

      if title == "custom"
        field_error :title, "Title should not be 'custom'"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
restpack_activity_service-0.0.13 lib/restpack_activity_service/commands/activity/create.rb