Class: ParamsReady::Helpers::Storage
- Inherits:
-
Object
- Object
- ParamsReady::Helpers::Storage
- Defined in:
- lib/params_ready/helpers/storage.rb
Instance Attribute Summary collapse
-
#parameters ⇒ Object
readonly
Returns the value of attribute parameters.
-
#relations ⇒ Object
readonly
Returns the value of attribute relations.
Instance Method Summary collapse
- #add_parameter(param) ⇒ Object
- #add_relation(relation) ⇒ Object
- #has_parameter?(name) ⇒ Boolean
- #has_relation?(name) ⇒ Boolean
-
#initialize ⇒ Storage
constructor
A new instance of Storage.
Constructor Details
#initialize ⇒ Storage
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
#parameters ⇒ Object (readonly)
Returns the value of attribute parameters.
4 5 6 |
# File 'lib/params_ready/helpers/storage.rb', line 4 def parameters @parameters end |
#relations ⇒ Object (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
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
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
15 16 17 |
# File 'lib/params_ready/helpers/storage.rb', line 15 def has_parameter?(name) parameters.key? name end |
#has_relation?(name) ⇒ Boolean
11 12 13 |
# File 'lib/params_ready/helpers/storage.rb', line 11 def has_relation?(name) relations.key? name end |