Class: Ion::Options

Inherits:
Object
  • Object
show all
Defined in:
lib/ion/options.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model) ⇒ Options

Returns a new instance of Options.



4
5
6
7
# File 'lib/ion/options.rb', line 4

def initialize(model)
  @model = model
  @indices = Hash.new { |h, k| h[k] = Hash.new }
end

Instance Attribute Details

#modelObject (readonly)

Returns the value of attribute model.



2
3
4
# File 'lib/ion/options.rb', line 2

def model
  @model
end

Instance Method Details

#index(type, name) ⇒ Object

Returns a certain index.

Examples:

@options.index(:text, :title) #=> <#Ion::Indices::Text>


20
21
22
# File 'lib/ion/options.rb', line 20

def index(type, name)
  @indices[type][name]
end

#index_typesObject



29
30
31
# File 'lib/ion/options.rb', line 29

def index_types
  indices.map(&:class).uniq
end

#indicesObject

Returns all indices.



25
26
27
# File 'lib/ion/options.rb', line 25

def indices
  @indices.values.map(&:values).flatten
end

#keyObject



13
14
15
# File 'lib/ion/options.rb', line 13

def key
  @key ||= Ion.key[model.name]  #=> 'Ion:Person'
end

#search(&blk) ⇒ Object



9
10
11
# File 'lib/ion/options.rb', line 9

def search(&blk)
  Ion::Search.new(self, &blk)
end