Class: SearchCopGrammar::Attributes::Base
- Inherits:
-
Object
- Object
- SearchCopGrammar::Attributes::Base
- Defined in:
- lib/search_cop_grammar/attributes.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#attribute ⇒ Object
readonly
Returns the value of attribute attribute.
-
#column_name ⇒ Object
readonly
Returns the value of attribute column_name.
-
#field_names ⇒ Object
readonly
Returns the value of attribute field_names.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#table_alias ⇒ Object
readonly
Returns the value of attribute table_alias.
Instance Method Summary collapse
- #compatible?(value) ⇒ Boolean
- #fulltext? ⇒ Boolean
-
#initialize(klass, table_alias, column_name, field_names, options = {}) ⇒ Base
constructor
A new instance of Base.
- #map(value) ⇒ Object
- #method_missing(name, *args, &block) ⇒ Object
- #respond_to_missing?(*args) ⇒ Boolean
Constructor Details
#initialize(klass, table_alias, column_name, field_names, options = {}) ⇒ Base
Returns a new instance of Base.
116 117 118 119 120 121 122 123 |
# File 'lib/search_cop_grammar/attributes.rb', line 116 def initialize(klass, table_alias, column_name, field_names, = {}) @attribute = klass.arel_table.alias(table_alias)[column_name] @klass = klass @table_alias = table_alias @column_name = column_name @field_names = field_names @options = ( || {}) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
149 150 151 152 153 154 155 |
# File 'lib/search_cop_grammar/attributes.rb', line 149 def method_missing(name, *args, &block) if @attribute.respond_to?(name) @attribute.send(name, *args, &block) else super end end |
Instance Attribute Details
#attribute ⇒ Object (readonly)
Returns the value of attribute attribute.
114 115 116 |
# File 'lib/search_cop_grammar/attributes.rb', line 114 def attribute @attribute end |
#column_name ⇒ Object (readonly)
Returns the value of attribute column_name.
114 115 116 |
# File 'lib/search_cop_grammar/attributes.rb', line 114 def column_name @column_name end |
#field_names ⇒ Object (readonly)
Returns the value of attribute field_names.
114 115 116 |
# File 'lib/search_cop_grammar/attributes.rb', line 114 def field_names @field_names end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
114 115 116 |
# File 'lib/search_cop_grammar/attributes.rb', line 114 def @options end |
#table_alias ⇒ Object (readonly)
Returns the value of attribute table_alias.
114 115 116 |
# File 'lib/search_cop_grammar/attributes.rb', line 114 def table_alias @table_alias end |
Instance Method Details
#compatible?(value) ⇒ Boolean
129 130 131 132 133 134 135 |
# File 'lib/search_cop_grammar/attributes.rb', line 129 def compatible?(value) map value true rescue SearchCop::IncompatibleDatatype false end |
#fulltext? ⇒ Boolean
137 138 139 |
# File 'lib/search_cop_grammar/attributes.rb', line 137 def fulltext? false end |
#map(value) ⇒ Object
125 126 127 |
# File 'lib/search_cop_grammar/attributes.rb', line 125 def map(value) value end |
#respond_to_missing?(*args) ⇒ Boolean
157 158 159 |
# File 'lib/search_cop_grammar/attributes.rb', line 157 def respond_to_missing?(*args) @attribute.respond_to?(*args) || super end |