Module: Xpub::DslAccessor
- Included in:
- Class
- Defined in:
- lib/xpub/dsl_accessor.rb
Instance Method Summary collapse
Instance Method Details
#dsl_accessor(name, *arg) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/xpub/dsl_accessor.rb', line 3 def dsl_accessor(name, *arg) define_method(name) do |*iarg| if iarg.empty? if !instance_variable_defined?("@#{name}") && arg[0] && arg[0][:default] instance_variable_set("@#{name}", arg[0][:default]) end instance_variable_get("@#{name}") else instance_variable_set("@#{name}", iarg[0]) end end end |