Class: FiltrosPersonalizados::FieldsPadroes::Boolean
- Inherits:
-
Field
- Object
- Field
- FiltrosPersonalizados::FieldsPadroes::Boolean
show all
- Defined in:
- lib/filtros_personalizados/fields_padroes/boolean.rb
Constant Summary
Constants inherited
from Field
Field::DIFERENTE, Field::ENTRE, Field::IGUAL, Field::MAIOR_QUE, Field::MENOR_QUE, Field::NENHUM, Field::TODOS
Instance Attribute Summary
Attributes inherited from Field
#association, #autocomplete_path, #collection, #collection_id, #collection_name, #field_name, #field_type, #is_open, #noactions, #options, #partial_name, #relation, #tipo_selecionado, #values
Instance Method Summary
collapse
Methods inherited from Field
#caption
Constructor Details
#initialize(args = {}) ⇒ Boolean
Returns a new instance of Boolean.
5
6
7
8
9
10
11
12
13
|
# File 'lib/filtros_personalizados/fields_padroes/boolean.rb', line 5
def initialize args={}
super
self.collection = [ Personalizaveis::TrueOrFalse.new(id: "true", nome: "Sim"),
Personalizaveis::TrueOrFalse.new(id: "false", nome: "Não")
]
self.collection_id = "id"
self.collection_name = "nome"
end
|
Instance Method Details
#acoes_disponiveis ⇒ Object
15
16
17
|
# File 'lib/filtros_personalizados/fields_padroes/boolean.rb', line 15
def acoes_disponiveis
[IGUAL]
end
|
#boolean_collection ⇒ Object
38
39
40
41
42
43
|
# File 'lib/filtros_personalizados/fields_padroes/boolean.rb', line 38
def boolean_collection
collection = []
collection << OpenStruct.new(id: "true", nome: "Sim")
collection << OpenStruct.new(id: "false", nome: "Não")
return collection
end
|
#file ⇒ Object
29
30
31
|
# File 'lib/filtros_personalizados/fields_padroes/boolean.rb', line 29
def file
"personalizaveis/#{ self.partial_name || 'boolean'}.html.erb"
end
|
#selecao ⇒ Object
33
34
35
|
# File 'lib/filtros_personalizados/fields_padroes/boolean.rb', line 33
def selecao
self.values.try(:first) == "true" ? self.field_name : ""
end
|
#where ⇒ Object
19
20
21
22
23
24
25
26
27
|
# File 'lib/filtros_personalizados/fields_padroes/boolean.rb', line 19
def where
unless self.values.blank?
if self.values.first == "true"
"#{self.relation}.#{self.field_name} IS NOT FALSE"
else
"#{self.relation}.#{self.field_name} IS FALSE"
end
end
end
|