Module: CouchModel::Base::Setup::ClassMethods

Defined in:
lib/couch_model/base/setup.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *arguments, &block) ⇒ Object



45
46
47
48
# File 'lib/couch_model/base/setup.rb', line 45

def method_missing(method_name, *arguments, &block)
  view = find_view method_name
  view ? view.collection(*arguments) : super
end

Instance Method Details

#countObject



41
42
43
# File 'lib/couch_model/base/setup.rb', line 41

def count
  all.total_count
end

#databaseObject



33
34
35
# File 'lib/couch_model/base/setup.rb', line 33

def database
  @database || raise(StandardError, "no database defined!")
end

#designObject



37
38
39
# File 'lib/couch_model/base/setup.rb', line 37

def design
  @design || raise(StandardError, "no database defined!")
end

#respond_to?(method_name, *arguments) ⇒ Boolean

Returns:

  • (Boolean)


50
51
52
53
# File 'lib/couch_model/base/setup.rb', line 50

def respond_to?(method_name, *arguments)
  view = find_view method_name
  view ? true : super
end

#setup_database(options = { }) ⇒ Object



26
27
28
29
30
31
# File 'lib/couch_model/base/setup.rb', line 26

def setup_database(options = { })
  initialize_database options
  initialize_design
  generate_class_view
  push_design options
end