Class: Object
- Inherits:
- BasicObject
- Defined in:
- lib/dynamic_assets/core_extensions.rb
Instance Method Summary collapse
Instance Method Details
#if_present(*value) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/dynamic_assets/core_extensions.rb', line 16 def if_present(*value) raise ArgumentError, "Specify either a value or a block but not both" if value.empty? != block_given? raise ArgumentError, "Too many arguments. Expected one." if value.length > 1 if !self.present? self elsif block_given? yield self else value.first end end |