Method: ActiveResource::Base#initialize
- Defined in:
- lib/active_resource/base.rb
#initialize(attributes = {}, persisted = false) ⇒ Base
Constructor method for new resources; the optional attributes parameter takes a hash of attributes for the new resource.
Examples
my_course = Course.new
my_course.name = "Western Civilization"
my_course.lecturer = "Don Trotter"
my_course.save
my_other_course = Course.new(:name => "Philosophy: Reason and Being", :lecturer => "Ralph Cling")
my_other_course.save
1239 1240 1241 1242 1243 1244 |
# File 'lib/active_resource/base.rb', line 1239 def initialize(attributes = {}, persisted = false) @attributes = {}.with_indifferent_access = {} @persisted = persisted load(attributes, false, persisted) end |