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.
-
#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, options = {}) ⇒ Base
constructor
A new instance of Base.
- #map(value) ⇒ Object
- #method_missing(name, *args, &block) ⇒ Object
- #respond_to?(*args) ⇒ Boolean
Constructor Details
#initialize(klass, table_alias, column_name, options = {}) ⇒ Base
Returns a new instance of Base.
96 97 98 99 100 101 102 |
# File 'lib/search_cop_grammar/attributes.rb', line 96 def initialize(klass, table_alias, column_name, = {}) @attribute = klass.arel_table.alias(table_alias)[column_name] @klass = klass @table_alias = table_alias @column_name = column_name @options = ( || {}) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
128 129 130 |
# File 'lib/search_cop_grammar/attributes.rb', line 128 def method_missing(name, *args, &block) @attribute.send(name, *args, &block) end |
Instance Attribute Details
#attribute ⇒ Object (readonly)
Returns the value of attribute attribute.
94 95 96 |
# File 'lib/search_cop_grammar/attributes.rb', line 94 def attribute @attribute end |
#column_name ⇒ Object (readonly)
Returns the value of attribute column_name.
94 95 96 |
# File 'lib/search_cop_grammar/attributes.rb', line 94 def column_name @column_name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
94 95 96 |
# File 'lib/search_cop_grammar/attributes.rb', line 94 def @options end |
#table_alias ⇒ Object (readonly)
Returns the value of attribute table_alias.
94 95 96 |
# File 'lib/search_cop_grammar/attributes.rb', line 94 def table_alias @table_alias end |
Instance Method Details
#compatible?(value) ⇒ Boolean
108 109 110 111 112 113 114 |
# File 'lib/search_cop_grammar/attributes.rb', line 108 def compatible?(value) map value true rescue SearchCop::IncompatibleDatatype false end |
#fulltext? ⇒ Boolean
116 117 118 |
# File 'lib/search_cop_grammar/attributes.rb', line 116 def fulltext? false end |
#map(value) ⇒ Object
104 105 106 |
# File 'lib/search_cop_grammar/attributes.rb', line 104 def map(value) value end |
#respond_to?(*args) ⇒ Boolean
132 133 134 |
# File 'lib/search_cop_grammar/attributes.rb', line 132 def respond_to?(*args) super(*args) || @attribute.respond_to?(*args) end |