Class: Application
- Inherits:
-
Ohm::Model
- Object
- Ohm::Model
- Application
- Includes:
- Ohm::Callbacks, Ohm::ExtraValidations, Ohm::Timestamping, Ohm::Typecast
- Defined in:
- lib/noah/applications.rb
Class Method Summary (collapse)
Instance Method Summary (collapse)
Class Method Details
+ (Object) find_or_create(opts = {})
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/noah/applications.rb', line 35 def find_or_create(opts = {}) begin find(opts).first.nil? ? (app = create(opts)) : (app = find(opts).first) if app.valid? app.save end app rescue Exception => e e. end end |
Instance Method Details
- (Boolean) is_new?
30 31 32 |
# File 'lib/noah/applications.rb', line 30 def is_new? self.created_at == self.updated_at end |
- (Object) stash_name (protected)
49 50 51 |
# File 'lib/noah/applications.rb', line 49 def stash_name @deleted_name = self.name end |
- (Object) to_hash
24 25 26 27 28 |
# File 'lib/noah/applications.rb', line 24 def to_hash arr = [] configurations.sort.each {|c| arr << c.to_hash} super.merge(:name => name, :created_at => created_at, :updated_at => updated_at, :configurations => arr) end |
- (Object) validate
18 19 20 21 22 |
# File 'lib/noah/applications.rb', line 18 def validate super assert_present :name assert_unique :name end |