Class: Philtre::Filter::Model

Inherits:
OpenStruct
  • Object
show all
Extended by:
ActiveModel::Naming
Defined in:
lib/philtre-rails/philtre_model.rb

Overview

These define the interface as used by the views. So this class is available for custom predicates.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.model_nameObject

Name this as ‘filter’, so the parameters come back from the form as that.



11
# File 'lib/philtre-rails/philtre_model.rb', line 11

def self.model_name; ActiveModel::Name.new(Philtre); end

Instance Method Details

#errorsObject



19
# File 'lib/philtre-rails/philtre_model.rb', line 19

def errors; @errors ||= ActiveModel::Errors.new(self); end

#persisted?Boolean

Rest of ActiveModel compliance, because

include ActiveModel::Model

messes with initialize, which breaks OpenStruct

Returns:

  • (Boolean)


16
# File 'lib/philtre-rails/philtre_model.rb', line 16

def persisted?; false; end

#to_keyObject



17
# File 'lib/philtre-rails/philtre_model.rb', line 17

def to_key; nil; end

#to_modelObject



21
# File 'lib/philtre-rails/philtre_model.rb', line 21

def to_model; self; end

#to_paramObject



18
# File 'lib/philtre-rails/philtre_model.rb', line 18

def to_param; nil; end

#to_partial_pathObject



20
# File 'lib/philtre-rails/philtre_model.rb', line 20

def to_partial_path; self.class.model_name.param_key; end