Sha256: f28ae3fd91ef04a558b29163c6e148847d6a2567d8f1fab5e1c1203bacafdc43

Contents?: true

Size: 731 Bytes

Versions: 7

Compression:

Stored size: 731 Bytes

Contents

module HaveAPI::Fs
  # The purpose of this class is to handle commands received via the
  # {Components::RemoteControlFile}.
  class RemoteControl
    # Call method #exec of a component at `path`.
    #
    # @param [Context] context
    # @param [String] path
    def self.execute(context, path)
      c = context.fs.send(:find_component, path)

      ret = c.exec

      case ret
      when true
        {status: true}

      when HaveAPI::Client::Response
        {status: ret.ok?, message: ret.message, errors: ret.errors}

      when HaveAPI::Client::ValidationError
        {status: false, message: ret.message, errors: ret.errors}

      else
        {status: false, message: 'unknown response'}
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
haveapi-fs-0.11.0 lib/haveapi/fs/remote_control.rb
haveapi-fs-0.10.0 lib/haveapi/fs/remote_control.rb
haveapi-fs-0.9.0 lib/haveapi/fs/remote_control.rb
haveapi-fs-0.8.0 lib/haveapi/fs/remote_control.rb
haveapi-fs-0.7.1 lib/haveapi/fs/remote_control.rb
haveapi-fs-0.7.0 lib/haveapi/fs/remote_control.rb
haveapi-fs-0.1.0 lib/haveapi/fs/remote_control.rb