Module: Devise::Activeresource::PatchMethods
- Defined in:
- lib/devise/activeresource/patch_methods.rb
Instance Method Summary collapse
- #[](attribute_name) ⇒ Object
- #assign_attributes(attributes = {}) ⇒ Object
- #initialize ⇒ Object
- #invalid? ⇒ Boolean
Instance Method Details
#[](attribute_name) ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/devise/activeresource/patch_methods.rb', line 33 def [](attribute_name) if attributes.include?(attribute_name) attributes[attribute_name] elsif respond_to?(attribute_name) send(attribute_name) else super end end |
#assign_attributes(attributes = {}) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/devise/activeresource/patch_methods.rb', line 21 def assign_attributes(attributes = {}) unless attributes.respond_to?(:to_hash) raise ArgumentError, 'expected attributes to be able to convert'\ " to Hash, got #{attributes.inspect}" end attributes = attributes.to_hash attributes.each do |key, value| send("#{key}=".to_sym, value) end end |
#initialize ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/devise/activeresource/patch_methods.rb', line 4 def initialize(*) super return unless self.class.schema keys = self.class.schema.select { |_k, v| v == 'timestamp' }.keys keys.each do |k| value = send(k.to_sym) next unless value.is_a?(String) send("#{k}=".to_sym, Time.parse(value)) end end |
#invalid? ⇒ Boolean
17 18 19 |
# File 'lib/devise/activeresource/patch_methods.rb', line 17 def invalid? !valid? end |