Class: Module

Inherits:
Object
  • Object
show all
Defined in:
lib/simply_useful/core_ext/module/property_delegation.rb

Instance Method Summary collapse

Instance Method Details

#delegate_property(*properties) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/simply_useful/core_ext/module/property_delegation.rb', line 5

def delegate_property *properties
  options = {}
  methods = []

  properties.each do |options_or_property|
    if options_or_property.is_a? Hash
      options.merge! options_or_property
    else
      methods << options_or_property
      methods << "#{options_or_property.to_s}="
    end
  end

  delegate *methods, options
end