Class: AttrSearchableGrammar::Attributes::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/attr_searchable_grammar/attributes.rb

Direct Known Subclasses

String, WithoutMatches

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attribute, klass, options = {}) ⇒ Base

Returns a new instance of Base.



82
83
84
85
86
# File 'lib/attr_searchable_grammar/attributes.rb', line 82

def initialize(attribute, klass, options = {})
  @attribute = attribute
  @klass = klass
  @options = (options || {})
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object



112
113
114
# File 'lib/attr_searchable_grammar/attributes.rb', line 112

def method_missing(name, *args, &block)
  @attribute.send name, *args, &block
end

Instance Attribute Details

#attributeObject (readonly)

Returns the value of attribute attribute.



80
81
82
# File 'lib/attr_searchable_grammar/attributes.rb', line 80

def attribute
  @attribute
end

#optionsObject (readonly)

Returns the value of attribute options.



80
81
82
# File 'lib/attr_searchable_grammar/attributes.rb', line 80

def options
  @options
end

Instance Method Details

#compatible?(value) ⇒ Boolean

Returns:



92
93
94
95
96
97
98
# File 'lib/attr_searchable_grammar/attributes.rb', line 92

def compatible?(value)
  map value

  true
rescue AttrSearchable::IncompatibleDatatype
  false
end

#fulltext?Boolean

Returns:



100
101
102
# File 'lib/attr_searchable_grammar/attributes.rb', line 100

def fulltext?
  false
end

#map(value) ⇒ Object



88
89
90
# File 'lib/attr_searchable_grammar/attributes.rb', line 88

def map(value)
  value
end

#respond_to?(*args) ⇒ Boolean

Returns:



116
117
118
# File 'lib/attr_searchable_grammar/attributes.rb', line 116

def respond_to?(*args)
  @attribute.respond_to? *args
end