Module: Typecaster
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/typecaster.rb,
lib/typecaster/version.rb
Defined Under Namespace
Modules: ClassMethods
Constant Summary collapse
- VERSION =
"0.0.1"
Instance Method Summary collapse
- #attributes ⇒ Object
- #initialize(attributes = {}) ⇒ Object
- #raw_attributes ⇒ Object
- #to_row ⇒ Object
Instance Method Details
#attributes ⇒ Object
50 51 52 |
# File 'lib/typecaster.rb', line 50 def attributes @attributes ||= self.class.attributes end |
#initialize(attributes = {}) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/typecaster.rb', line 38 def initialize(attributes={}) raw_attributes.each do |name, attributes| if attributes.has_key?(:default) define_instance_variable(name, attributes[:default]) end end attributes.each do |key, value| send "#{key}=", value end end |
#raw_attributes ⇒ Object
54 55 56 |
# File 'lib/typecaster.rb', line 54 def raw_attributes @raw_attributes ||= self.class.raw_attributes end |
#to_row ⇒ Object
58 59 60 |
# File 'lib/typecaster.rb', line 58 def to_row attributes.values.join("") end |