Module: BN::Helpers::HasAttributes::ClassMethods
- Defined in:
- lib/bn/helpers/has_attributes.rb
Overview
The class methods to be mixed in when included.
Instance Method Summary collapse
Instance Method Details
#attribute(name, options = {}, &block) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/bn/helpers/has_attributes.rb', line 7 def attribute(name, ={}, &block) = .to_h attr_reader(name) define_method("#{name}=") do |value| value = instance_exec(value, , &block) unless block.nil? instance_variable_set("@#{name}", value) end end |