Module: Enumerable
- Included in:
- ActiveComponent::Base
- Defined in:
- lib/active_component/core_extensions.rb
Instance Method Summary collapse
-
#find_a(klass) ⇒ Object
Returns the first object of the specified class contained in enumerable.
-
#includes_a?(klass) ⇒ Boolean
Determines if enumerable contains an object of the specified class.
-
#transmogrify(*options) ⇒ Object
Transmogrify yields each element to the given block.
Instance Method Details
#find_a(klass) ⇒ Object
Returns the first object of the specified class contained in enumerable
65 66 67 68 69 70 |
# File 'lib/active_component/core_extensions.rb', line 65 def find_a(klass) each do |e| return e if e.is_a? klass end nil end |
#includes_a?(klass) ⇒ Boolean
Determines if enumerable contains an object of the specified class
57 58 59 60 61 62 |
# File 'lib/active_component/core_extensions.rb', line 57 def includes_a?(klass) each do |e| return true if e.is_a? klass end false end |
#transmogrify(*options) ⇒ Object
Transmogrify yields each element to the given block
44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/active_component/core_extensions.rb', line 44 def transmogrify(*) if .include? :yield_index each_with_index do |element, index| yield element, index end else each do |element| yield element end end end |