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.



71
72
73
74
75
# File 'lib/attr_searchable_grammar/attributes.rb', line 71

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



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

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

Instance Attribute Details

#attributeObject (readonly)

Returns the value of attribute attribute.



69
70
71
# File 'lib/attr_searchable_grammar/attributes.rb', line 69

def attribute
  @attribute
end

#optionsObject (readonly)

Returns the value of attribute options.



69
70
71
# File 'lib/attr_searchable_grammar/attributes.rb', line 69

def options
  @options
end

Instance Method Details

#compatible?(value) ⇒ Boolean

Returns:



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

def compatible?(value)
  map value

  true
rescue AttrSearchable::IncompatibleDatatype
  false
end

#fulltext?Boolean

Returns:



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

def fulltext?
  false
end

#map(value) ⇒ Object



77
78
79
# File 'lib/attr_searchable_grammar/attributes.rb', line 77

def map(value)
  value
end

#respond_to?(*args) ⇒ Boolean

Returns:



105
106
107
# File 'lib/attr_searchable_grammar/attributes.rb', line 105

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