module Mince::Model::Finders::ClassMethods

Public Instance Methods

all() click to toggle source

Returns all models from the data model

# File lib/mince/model/finders.rb, line 42
def all
  data_model.all.map{|a| new a }
end
all_before(field, value) click to toggle source

Returns all models where the field has a value that is less than the given value

# File lib/mince/model/finders.rb, line 53
def all_before(field, value)
  data_model.all_before(field, value).map{|a| new(a) }
end
all_by_field(field, value) click to toggle source

Finds all fields that match the given field value pair

# File lib/mince/model/finders.rb, line 27
def all_by_field(field, value)
  data_model.all_by_field(field, value).map{|a| new(a) }
end
all_by_fields(hash) click to toggle source

Finds all fields that match the given hash

# File lib/mince/model/finders.rb, line 32
def all_by_fields(hash)
  data_model.all_by_fields(hash).map{|a| new(a) }
end
find(id) click to toggle source

Returns a model that matches a given id, returns nil if none found

# File lib/mince/model/finders.rb, line 47
def find(id)
  a = data_model.find(id)
  new a if a
end
find_by_field(field, value) click to toggle source

Finds a model for the given field value pair

# File lib/mince/model/finders.rb, line 15
def find_by_field(field, value)
  d = data_model.find_by_field(field, value)
  new d if d
end
find_by_fields(hash) click to toggle source

Finds a model for the given hash

# File lib/mince/model/finders.rb, line 21
def find_by_fields(hash)
  d = data_model.find_by_fields(hash)
  new d if d
end
find_or_initialize_by(hash) click to toggle source

Finds or initializes a model for the given hash

# File lib/mince/model/finders.rb, line 37
def find_or_initialize_by(hash)
  find_by_fields(hash) || new(hash)
end