Sha256: e381333c3433ff76f0dd279de75e1a8382b578ef9552d61914d44e46581a9731
Contents?: true
Size: 1.01 KB
Versions: 2
Compression:
Stored size: 1.01 KB
Contents
module RestPack::Activity::Service::Commands module Activity class Create < RestPack::Service::Command 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 end def init inputs[:data] = raw_inputs[:data] if raw_inputs[:data] if latitude.present? || longitude.present? if latitude.present? != longitude.present? service_error "Both Latitude and Longitude are required" end end if title == "error" service_error "This is a service error" end if title == "custom" field_error :title, "Title should not be 'custom'" end end def execute activity = Models::Activity.create(inputs) Serializers::Activity.as_json(activity) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
restpack_activity_service-0.0.12 | lib/restpack_activity_service/commands/activity/create.rb |
restpack_activity_service-0.0.11 | lib/restpack_activity_service/commands/activity/create.rb |