Class: Sequel::Generators::ActiveModel

Inherits:
Rails::Generators::ActiveModel
  • Object
show all
Defined in:
lib/rails/generators/sequel/active_model.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.all(klass) ⇒ Object



6
7
8
# File 'lib/rails/generators/sequel/active_model.rb', line 6

def self.all(klass)
  "#{klass}.all" 
end

.build(klass, params = nil) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/rails/generators/sequel/active_model.rb', line 14

def self.build(klass, params=nil)
  if params then
    "#{klass}.new(#{params})"
  else
    "#{klass}.new"
  end
end

.find(klass, params = nil) ⇒ Object



10
11
12
# File 'lib/rails/generators/sequel/active_model.rb', line 10

def self.find(klass, params=nil)
  "#{klass}[#{params}]"
end

Instance Method Details

#destroyObject



35
36
37
# File 'lib/rails/generators/sequel/active_model.rb', line 35

def destroy
  "#{name}.destroy"
end

#errorsObject



31
32
33
# File 'lib/rails/generators/sequel/active_model.rb', line 31

def errors
  "#{name}.errors"
end

#saveObject



22
23
24
25
# File 'lib/rails/generators/sequel/active_model.rb', line 22

def save
  # probably will set raise_on_save_failure to false by default when using Rails
  "#{name}.save"
end

#update_attributes(params = nil) ⇒ Object



27
28
29
# File 'lib/rails/generators/sequel/active_model.rb', line 27

def update_attributes(params=nil)
  "#{name}.update(#{params}) != false"
end