Sha256: efb54956c253649b461d95b09bd058e54e02f71fd3a6d1c64dfae3a3a66d12f6

Contents?: true

Size: 815 Bytes

Versions: 4

Compression:

Stored size: 815 Bytes

Contents

module RestPack::Activity::Service::Commands::Activity
  class Update < RestPack::Service::Command
    required do
      integer :id
      integer :application_id
    end

    optional do
      string  :title, empty: true
      string  :content
      string  :tags, empty: true
      string  :access, empty: true
      float   :latitude
      float   :longitude
    end

    def init
      inputs[:data] = raw_inputs[:data] if raw_inputs[:data]
    end

    def execute
      activity = RestPack::Activity::Service::Models::Activity.find_by_id_and_application_id(inputs[:id], inputs[:application_id])

      if activity
        activity.update_attributes(inputs)
        RestPack::Activity::Service::Serializers::ActivitySerializer.as_json(activity)
      else
        status :not_found
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
restpack_activity_service-0.0.10 lib/restpack_activity_service/services/activity/update.rb
restpack_activity_service-0.0.9 lib/restpack_activity_service/services/activity/update.rb
restpack_activity_service-0.0.8 lib/restpack_activity_service/services/activity/update.rb
restpack_activity_service-0.0.7 lib/restpack_activity_service/services/activity/update.rb