Class: Infold::Condition
- Inherits:
-
Object
- Object
- Infold::Condition
- Includes:
- ActiveModel::Model
- Defined in:
- lib/infold/property/condition.rb
Instance Attribute Summary collapse
-
#association_search_form_kind ⇒ Object
Returns the value of attribute association_search_form_kind.
-
#association_seq ⇒ Object
Returns the value of attribute association_seq.
-
#field ⇒ Object
readonly
Returns the value of attribute field.
-
#index_association_name ⇒ Object
Returns the value of attribute index_association_name.
-
#index_form_kind ⇒ Object
Returns the value of attribute index_form_kind.
-
#index_seq ⇒ Object
Returns the value of attribute index_seq.
- #sign ⇒ Object
Instance Method Summary collapse
- #form_kind(view) ⇒ Object
- #in_association_search? ⇒ Boolean
- #in_index? ⇒ Boolean
-
#initialize(field, **attrs) ⇒ Condition
constructor
A new instance of Condition.
- #scope ⇒ Object
- #sign_label ⇒ Object
Constructor Details
#initialize(field, **attrs) ⇒ Condition
Returns a new instance of Condition.
13 14 15 16 |
# File 'lib/infold/property/condition.rb', line 13 def initialize(field, **attrs) @field = field super(**attrs) end |
Instance Attribute Details
#association_search_form_kind ⇒ Object
Returns the value of attribute association_search_form_kind.
7 8 9 |
# File 'lib/infold/property/condition.rb', line 7 def association_search_form_kind @association_search_form_kind end |
#association_seq ⇒ Object
Returns the value of attribute association_seq.
7 8 9 |
# File 'lib/infold/property/condition.rb', line 7 def association_seq @association_seq end |
#field ⇒ Object (readonly)
Returns the value of attribute field.
5 6 7 |
# File 'lib/infold/property/condition.rb', line 5 def field @field end |
#index_association_name ⇒ Object
Returns the value of attribute index_association_name.
7 8 9 |
# File 'lib/infold/property/condition.rb', line 7 def index_association_name @index_association_name end |
#index_form_kind ⇒ Object
Returns the value of attribute index_form_kind.
7 8 9 |
# File 'lib/infold/property/condition.rb', line 7 def index_form_kind @index_form_kind end |
#index_seq ⇒ Object
Returns the value of attribute index_seq.
7 8 9 |
# File 'lib/infold/property/condition.rb', line 7 def index_seq @index_seq end |
#sign ⇒ Object
18 19 20 |
# File 'lib/infold/property/condition.rb', line 18 def sign (@sign.presence || :eq).to_sym end |
Instance Method Details
#form_kind(view) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/infold/property/condition.rb', line 34 def form_kind(view) # indexとassociation_searchでform_kindが異なる場合に対応 _form_kind = (view == :index ? index_form_kind : association_search_form_kind).to_s if _form_kind == 'association_search' && field.association&.belongs_to? :association_search elsif _form_kind == 'select' :select elsif sign == :any && field.enum.present? :checkbox elsif field.type == :boolean || _form_kind == 'switch' :switch else :text end end |
#in_association_search? ⇒ Boolean
30 31 32 |
# File 'lib/infold/property/condition.rb', line 30 def in_association_search? association_search_form_kind.present? end |
#in_index? ⇒ Boolean
26 27 28 |
# File 'lib/infold/property/condition.rb', line 26 def in_index? index_form_kind.present? end |
#scope ⇒ Object
22 23 24 |
# File 'lib/infold/property/condition.rb', line 22 def scope "#{field.name}_#{sign}" end |
#sign_label ⇒ Object
50 51 52 53 54 55 56 57 58 |
# File 'lib/infold/property/condition.rb', line 50 def sign_label case sign when :lteq then 'or less' when :gteq then 'or more' when :full_like then 'like %...%' when :start_with then 'like ...%' else '=' end end |