Sha256: 5a5bf17859d0343c1adeb67cb68c3d8dc0dee8868e39fa4d8334e261ea975b94

Contents?: true

Size: 760 Bytes

Versions: 7

Compression:

Stored size: 760 Bytes

Contents

module HaveAPI::Fs::Components
  class ActionInput < Directory
    component :action_input
    attr_reader :action_dir

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

    def contents
      super + parameters.keys.map(&:to_s)
    end

    def parameters
      @action_dir.action.input_params
    end

    def values
      Hash[children.select { |n, c| c.is_a?(Parameter) && c.set? }.map { |n, c| [n, c.value] }]
    end

    def title
      'Input parameters'
    end

    protected
    def new_child(name)
      if child = super
        child

      elsif @action_dir.action.input_params.has_key?(name)
        [Parameter, @action_dir.action, name, :input]

      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_input.rb
haveapi-fs-0.10.0 lib/haveapi/fs/components/action_input.rb
haveapi-fs-0.9.0 lib/haveapi/fs/components/action_input.rb
haveapi-fs-0.8.0 lib/haveapi/fs/components/action_input.rb
haveapi-fs-0.7.1 lib/haveapi/fs/components/action_input.rb
haveapi-fs-0.7.0 lib/haveapi/fs/components/action_input.rb
haveapi-fs-0.1.0 lib/haveapi/fs/components/action_input.rb