Module: Turbine::Properties
Instance Method Summary collapse
-
#get(key) ⇒ Object
Public: Returns a single property on the model.
-
#properties ⇒ Object
Public: Returns the properties associated with the model.
-
#properties=(new_props) ⇒ Object
Public: Mass-assigns properties to the model.
-
#set(key, value) ⇒ Object
Public: Sets a single property on the model.
Instance Method Details
#get(key) ⇒ Object
Public: Returns a single property on the model.
key - The property to be retrieved.
Returns the value or nil if the property does not exist.
43 44 45 |
# File 'lib/turbine/properties.rb', line 43 def get(key) properties[key] end |
#properties ⇒ Object
Public: Returns the properties associated with the model.
Returns a hash containing the properties. This is the original properties hash, not a duplicate.
8 9 10 |
# File 'lib/turbine/properties.rb', line 8 def properties @properties ||= Hash.new end |
#properties=(new_props) ⇒ Object
Public: Mass-assigns properties to the model.
new_props - A hash containing zero or more properties. The internal
properties hash is set to whatever parameters you provide; a
duplicate is not made before assignment. You may provide
+nil+ to remove all properties.
Returns the properties.
20 21 22 23 24 25 26 |
# File 'lib/turbine/properties.rb', line 20 def properties=(new_props) unless new_props.is_a?(Hash) || new_props.nil? raise InvalidPropertiesError.new(self, new_props) end @properties = new_props end |
#set(key, value) ⇒ Object
Public: Sets a single property on the model.
key - The property name. value - The value to be set.
Returns the value.
34 35 36 |
# File 'lib/turbine/properties.rb', line 34 def set(key, value) properties[key] = value end |