Module: RSS::Utils::InheritedReader
- Included in:
- Element, Maker::Base
- Defined in:
- lib/rss/utils.rb
Instance Method Summary collapse
- #inherited_array_reader(constant_name) ⇒ Object
- #inherited_hash_reader(constant_name) ⇒ Object
- #inherited_reader(constant_name) ⇒ Object
Instance Method Details
#inherited_array_reader(constant_name) ⇒ Object
169 170 171 172 173 |
# File 'lib/rss/utils.rb', line 169 def inherited_array_reader(constant_name) inherited_reader(constant_name) do |result, current| current + result end end |
#inherited_hash_reader(constant_name) ⇒ Object
175 176 177 178 179 |
# File 'lib/rss/utils.rb', line 175 def inherited_hash_reader(constant_name) inherited_reader(constant_name) do |result, current| result.merge(current) end end |
#inherited_reader(constant_name) ⇒ Object
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/rss/utils.rb', line 153 def inherited_reader(constant_name) base_class = inherited_base result = base_class.const_get(constant_name) found_base_class = false ancestors.reverse_each do |klass| if found_base_class if klass.const_defined?(constant_name) result = yield(result, klass.const_get(constant_name)) end else found_base_class = klass == base_class end end result end |