Module: ActionAnnotation::Annotations::InstanceMethods
- Defined in:
- lib/action_annotation/annotations.rb
Overview
Contains methods for fetching the value as defined by the source-part of a description.
Instance Method Summary collapse
-
#value_of_source(source) ⇒ Object
Returns the value that is associated with a source *
source
Either a symbol or an evaluatable string. -
#values_of_source(source) ⇒ Object
Returns a list of values that is associated with a source *
source
Either a symbol or an evaluatable string.
Instance Method Details
#value_of_source(source) ⇒ Object
Returns the value that is associated with a source
-
source
Either a symbol or an evaluatable string
value_of_binding(:id) # == params[:id]
value_of_binding("@value") # == @value
186 187 188 189 190 191 192 193 194 |
# File 'lib/action_annotation/annotations.rb', line 186 def value_of_source(source) if source.is_a? String instance_eval(source) elsif source.is_a? Symbol params[source] else raise ArgumentError, "Unknown source #{source}" end end |
#values_of_source(source) ⇒ Object
Returns a list of values that is associated with a source
-
source
Either a symbol or an evaluatable string
174 175 176 177 178 |
# File 'lib/action_annotation/annotations.rb', line 174 def values_of_source(source) value = value_of_source(source) # TODO: what happens in case of a hash? value.is_a?(Array) ? value : [value] end |