Class: ParamsReady::Helpers::Storage

Inherits:
Object
  • Object
show all
Defined in:
lib/params_ready/helpers/storage.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeStorage

Returns a new instance of Storage.



6
7
8
9
# File 'lib/params_ready/helpers/storage.rb', line 6

def initialize
  @parameters = Hash.new
  @relations = Hash.new
end

Instance Attribute Details

#parametersObject (readonly)

Returns the value of attribute parameters.



4
5
6
# File 'lib/params_ready/helpers/storage.rb', line 4

def parameters
  @parameters
end

#relationsObject (readonly)

Returns the value of attribute relations.



4
5
6
# File 'lib/params_ready/helpers/storage.rb', line 4

def relations
  @relations
end

Instance Method Details

#add_parameter(param) ⇒ Object

Raises:



24
25
26
27
# File 'lib/params_ready/helpers/storage.rb', line 24

def add_parameter(param)
  raise ParamsReadyError, "Parameter already exists: #{param.name}" if self.has_parameter?(param.name)
  @parameters[param.name] = param
end

#add_relation(relation) ⇒ Object

Raises:



19
20
21
22
# File 'lib/params_ready/helpers/storage.rb', line 19

def add_relation(relation)
  raise ParamsReadyError, "Relation already exists: #{relation.name}" if self.has_relation?(relation.name)
  @relations[relation.name] = relation
end

#has_parameter?(name) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/params_ready/helpers/storage.rb', line 15

def has_parameter?(name)
  parameters.key? name
end

#has_relation?(name) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/params_ready/helpers/storage.rb', line 11

def has_relation?(name)
  relations.key? name
end