Class: ParamsReady::Parameter::StateDefinition

Inherits:
StructParameterDefinition show all
Defined in:
lib/params_ready/parameter/state.rb

Instance Attribute Summary collapse

Attributes inherited from AbstractStructParameterDefinition

#key_map, #names

Attributes inherited from Definition

#default

Attributes inherited from AbstractDefinition

#altn, #name

Instance Method Summary collapse

Methods inherited from StructParameterDefinition

#add_map, #ensure_canonical, #remap?

Methods inherited from AbstractStructParameterDefinition

#add_child, #child_definition, #duplicate_value, #freeze_value, #has_child?, #infer_default, #set_default

Methods inherited from Definition

#canonical_default, #default_defined?, #fetch_callable_default, #fetch_default, #finish, #memoize?, #name_for_formatter, #no_input?, #no_output?, #postprocess, #preprocess, #restricted_for_format?, #set_local, #set_no_input, #set_postprocessor, #set_preprocessor

Methods inherited from AbstractDefinition

#create, #finish, #from_hash, #from_input, #normalize_alternative_name, #parameter_class

Methods included from Extensions::Freezer

#freeze_variable, #freeze_variables, #variables_to_freeze

Methods included from Extensions::Finalizer

#obligatory, #obligatory!

Methods included from Extensions::ClassReaderWriter

#class_reader_writer

Methods included from Extensions::LateInit

#late_init

Methods included from Extensions::Collection

#collection

Methods included from Extensions::Finalizer::InstanceMethods

#finish

Methods included from Extensions::Freezer::InstanceMethods

#freeze

Constructor Details

#initialize(*args, **opts) ⇒ StateDefinition

Returns a new instance of StateDefinition.



116
117
118
119
# File 'lib/params_ready/parameter/state.rb', line 116

def initialize(*args, **opts)
  super *args, **opts
  @relations = Set.new
end

Instance Attribute Details

#relationsObject (readonly)

Returns the value of attribute relations.



114
115
116
# File 'lib/params_ready/parameter/state.rb', line 114

def relations
  @relations
end

Instance Method Details

#add_relation(relation) ⇒ Object



121
122
123
124
125
126
127
# File 'lib/params_ready/parameter/state.rb', line 121

def add_relation(relation)
  if @relations.include? relation.name
    raise ParamsReadyError, "Relation already there '#{relation.name}'"
  end
  @relations << relation.name
  add_child relation
end