Sha256: ac2acd7eebee24c9a0ba27f8207937665b163633dbdabc2a9df1ddf37b06df5d
Contents?: true
Size: 605 Bytes
Versions: 4
Compression:
Stored size: 605 Bytes
Contents
module HasAttributes def initialize(attributes = nil) self.attributes = attributes yield self if block_given? end def attributes=(attributes) # , guard_protected_attributes = true #attributes = filter_attributes(attributes) if !attributes.blank? && guard_protected_attributes attributes.each do |key,value| send(key.to_s + '=', value) end if attributes end def attributes attributes = instance_variables attributes.delete("@errors") Hash[*attributes.collect { |attribute| [attribute[1..-1].to_sym, instance_variable_get(attribute)] }.flatten] end end
Version data entries
4 entries across 4 versions & 2 rubygems
Version | Path |
---|---|
maciej-simply_useful-0.1.2 | lib/has_attributes.rb |
maciej-simply_useful-0.1.3 | lib/has_attributes.rb |
simply_useful-0.1.6 | lib/has_attributes.rb |
simply_useful-0.1.5 | lib/has_attributes.rb |