Sha256: e8f1a09fbaf20d8dab25567a5284b4538b7759806e813fc154ae716cba7921ae

Contents?: true

Size: 797 Bytes

Versions: 7

Compression:

Stored size: 797 Bytes

Contents

module HaveAPI::Fs::Components
  class ActionErrors < Directory
    component :action_errors

    class ActionError < File
      def initialize(errors)
        @errors = errors
      end

      def read
        @errors.join("\n") + "\n"
      end
    end

    def initialize(action_dir, *args)
      super(*args)
      @action_dir = action_dir
    end

    def contents
      ret = super
      return ret unless @errors
      ret.concat(@errors.keys.map(&:to_s))
      ret
    end

    def set(errors)
      changed
      @errors = errors
    end

    def title
      'Errors'
    end

    protected
    def new_child(name)
      if child = super
        child

      elsif @errors && @errors.has_key?(name)
        [ActionError, @errors[name]]

      else
        nil
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

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