Class: Dao::Errors::KeyPrefixer
- Inherits:
-
Object
- Object
- Dao::Errors::KeyPrefixer
- Defined in:
- lib/dao/errors.rb
Instance Attribute Summary collapse
-
#global ⇒ Object
Returns the value of attribute global.
-
#object ⇒ Object
Returns the value of attribute object.
Instance Method Summary collapse
-
#initialize(object) ⇒ KeyPrefixer
constructor
A new instance of KeyPrefixer.
- #prefix(key) ⇒ Object
Constructor Details
#initialize(object) ⇒ KeyPrefixer
Returns a new instance of KeyPrefixer.
266 267 268 269 270 271 272 273 274 275 276 277 |
# File 'lib/dao/errors.rb', line 266 def initialize(object) @object = object @prefix = if @object && @object.respond_to?(:model_name) @object.model_name.to_s.underscore else nil end @global = Array(Global) end |
Instance Attribute Details
#global ⇒ Object
Returns the value of attribute global.
264 265 266 |
# File 'lib/dao/errors.rb', line 264 def global @global end |
#object ⇒ Object
Returns the value of attribute object.
263 264 265 |
# File 'lib/dao/errors.rb', line 263 def object @object end |
Instance Method Details
#prefix(key) ⇒ Object
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 |
# File 'lib/dao/errors.rb', line 279 def prefix(key) is_global_key = key == @global || Array(key) == @global if @prefix if is_global_key @prefix else ["#{ @prefix }.#{ key[0] }", *key[1..-1]] end else if is_global_key 'global' else key end end end |