Class: Bricolage::DataSourceParam

Inherits:
Param
  • Object
show all
Defined in:
lib/bricolage/parameters.rb

Instance Attribute Summary

Attributes inherited from Param

#arg_spec, #name

Instance Method Summary collapse

Methods inherited from Param

#have_arg?, #inspect, #option_name, #optional?, #parse_option_value, #parse_value, #publish?, #required?

Constructor Details

#initialize(kind, name = 'data-source', description = 'Main data source.', optional: true, publish: false) ⇒ DataSourceParam

Returns a new instance of DataSourceParam.

Raises:



447
448
449
450
451
# File 'lib/bricolage/parameters.rb', line 447

def initialize(kind, name = 'data-source', description = 'Main data source.', optional: true, publish: false)
  raise FatalError, "no data source kind declared" unless kind
  super name, 'NAME', description, optional: optional, publish: publish
  @kind = kind
end

Instance Method Details

#default_value(ctx, vars) ⇒ Object



457
458
459
# File 'lib/bricolage/parameters.rb', line 457

def default_value(ctx, vars)
  ctx.get_data_source(@kind, nil)
end

#descriptionObject



453
454
455
# File 'lib/bricolage/parameters.rb', line 453

def description
  "#{super} [default: #{@kind}]"
end

#materialize(value, ctx, vars) ⇒ Object



461
462
463
# File 'lib/bricolage/parameters.rb', line 461

def materialize(value, ctx, vars)
  ctx.get_data_source(@kind, expand(value, vars))
end

#variables(ds) ⇒ Object



465
466
467
# File 'lib/bricolage/parameters.rb', line 465

def variables(ds)
  wrap_variable_value(ds.name)
end