Class: Bricolage::Param

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

Overview

class Parameters

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, arg_spec, description, optional: false, publish: false) ⇒ Param

Returns a new instance of Param.



261
262
263
264
265
266
267
# File 'lib/bricolage/parameters.rb', line 261

def initialize(name, arg_spec, description, optional: false, publish: false)
  @name = name
  @arg_spec = arg_spec
  @description = description
  @optional = optional
  @publish = publish
end

Instance Attribute Details

#arg_specObject (readonly)

Returns the value of attribute arg_spec.



276
277
278
# File 'lib/bricolage/parameters.rb', line 276

def arg_spec
  @arg_spec
end

#descriptionObject (readonly)

Returns the value of attribute description.



270
271
272
# File 'lib/bricolage/parameters.rb', line 270

def description
  @description
end

#nameObject (readonly)

Returns the value of attribute name.



269
270
271
# File 'lib/bricolage/parameters.rb', line 269

def name
  @name
end

Instance Method Details

#have_arg?Boolean

Returns:

  • (Boolean)


278
279
280
# File 'lib/bricolage/parameters.rb', line 278

def have_arg?
  !!@arg_spec
end

#inspectObject



295
296
297
298
299
300
301
# File 'lib/bricolage/parameters.rb', line 295

def inspect
  attrs = [
    (@optional ? 'optional' : 'required'),
    (@publish ? 'publish' : nil)
  ].compact.join(',')
  "\#<#{self.class} #{name} #{attrs}>"
end

#option_nameObject



272
273
274
# File 'lib/bricolage/parameters.rb', line 272

def option_name
  name
end

#optional?Boolean

Returns:

  • (Boolean)


282
283
284
# File 'lib/bricolage/parameters.rb', line 282

def optional?
  @optional
end

#parse_option_value(arg, acc) ⇒ Object

Value Handling



307
308
309
310
# File 'lib/bricolage/parameters.rb', line 307

def parse_option_value(arg, acc)
  return nil if arg.nil?
  arg
end

#parse_value(value) ⇒ Object



312
313
314
# File 'lib/bricolage/parameters.rb', line 312

def parse_value(value)
  value
end

#publish?Boolean

“published” parameter defines SQL variable.

Returns:

  • (Boolean)


291
292
293
# File 'lib/bricolage/parameters.rb', line 291

def publish?
  @publish
end

#required?Boolean

Returns:

  • (Boolean)


286
287
288
# File 'lib/bricolage/parameters.rb', line 286

def required?
  not optional?
end