Sha256: 9aabc3d9febfb7c27cca77766f507d784c385684688f61699cca3bb13f01b9ab

Contents?: true

Size: 728 Bytes

Versions: 4

Compression:

Stored size: 728 Bytes

Contents

module Riyic
    module AttributeMixin
        # si extendemos unha clase con este modulo os metodos fanse de clase
        # si incluimos esta clase os metodos fanse de instancia
        
        def attr_setter(*method_names)
             method_names.each do |name|
                send :define_method, name do |data|
                    instance_variable_set "@#{name}".to_sym, data 
                end
            end
        end
            
        def varargs_setter(*method_names)
                
            method_names.each do |name|
                send :define_method, name do |*data|
                    instance_variable_set "@#{name}".to_sym, data
                end
            end
        end

    end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
lambom-0.2.1 lib/lambom/attribute_mixin.rb
lambom-0.2.0 lib/lambom/attribute_mixin.rb
lambom-0.1.2 lib/lambom/attribute_mixin.rb
lambom-0.1.1 lib/lambom/attribute_mixin.rb