Module: Realm::Mixins::Decorator
- Defined in:
- lib/realm/mixins/decorator.rb
Class Method Summary collapse
-
.[](decorated) ⇒ Object
rubocop:disable Metrics/MethodLength.
Class Method Details
.[](decorated) ⇒ Object
rubocop:disable Metrics/MethodLength
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/realm/mixins/decorator.rb', line 6 def self.[](decorated) # rubocop:disable Metrics/MethodLength Module.new do def method_missing(...) _decorated.send(...) end def respond_to_missing?(...) _decorated.respond_to?(...) end if decorated.to_s[0] == '@' define_method :initialize do |value| instance_variable_set(decorated, value) end define_method :_decorated do instance_variable_get(decorated) end else define_method :_decorated do send(decorated) end end end end |