Sha256: d59fccadb9189e30ea9b2f612d13e6eabb43bd5802b55997215abad92d44feb9

Contents?: true

Size: 990 Bytes

Versions: 6

Compression:

Stored size: 990 Bytes

Contents

module HaveAPI::Fs::Components
  class MetaOutput < Directory
    component :meta_output
    help_file :action_output
    attr_accessor :data
    attr_reader :scope

    def initialize(action_dir, scope, data = nil, *args)
      super(*args)

      @action_dir = action_dir
      @scope = scope
      @data = data
    end

    def contents
      ret = super
      return ret unless @data

      ret.concat(parameters.keys.map(&:to_s))
      ret
    end

    def parameters
      @action_dir.action.instance_variable_get('@spec')[:meta][@scope][:output][:parameters]
    end

    def title
      'Output metadata parameters'
    end

    protected
    def new_child(name)
      if child = super
        child

      elsif !@data
        nil

      elsif parameters.has_key?(name)
        [
            Parameter,
            @action_dir.action,
            name,
            :output,
            @data,
            meta: @scope,
        ]

      else
        nil
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

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