Class: Dnif::Index

Inherits:
Object
  • Object
show all
Defined in:
lib/dnif/index.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ Index

Returns a new instance of Index.



8
9
10
11
12
13
# File 'lib/dnif/index.rb', line 8

def initialize(&block)
  @fields = []
  @attributes = {}

  self.instance_eval(&block)
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



5
6
7
# File 'lib/dnif/index.rb', line 5

def attributes
  @attributes
end

#conditionsObject (readonly)

Returns the value of attribute conditions.



6
7
8
# File 'lib/dnif/index.rb', line 6

def conditions
  @conditions
end

#fieldsObject (readonly)

Returns the value of attribute fields.



4
5
6
# File 'lib/dnif/index.rb', line 4

def fields
  @fields
end

Instance Method Details

#attribute(name, options) ⇒ Object



19
20
21
22
23
# File 'lib/dnif/index.rb', line 19

def attribute(name, options)
  raise "You must specify the attribute type (:integer, :datetime, :date, :boolean, :float)" if options[:type].nil?

  @attributes[name] = options[:type]
end

#field(name) ⇒ Object



15
16
17
# File 'lib/dnif/index.rb', line 15

def field(name)
  @fields << name
end

#where(*conditions) ⇒ Object



25
26
27
# File 'lib/dnif/index.rb', line 25

def where(*conditions)
  @conditions = conditions
end