Class: Dnif::Index
- Inherits:
-
Object
- Object
- Dnif::Index
- Defined in:
- lib/dnif/index.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#conditions ⇒ Object
readonly
Returns the value of attribute conditions.
-
#fields ⇒ Object
readonly
Returns the value of attribute fields.
Instance Method Summary collapse
- #attribute(name, options) ⇒ Object
- #field(name) ⇒ Object
-
#initialize(&block) ⇒ Index
constructor
A new instance of Index.
- #where(*conditions) ⇒ Object
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
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
5 6 7 |
# File 'lib/dnif/index.rb', line 5 def attributes @attributes end |
#conditions ⇒ Object (readonly)
Returns the value of attribute conditions.
6 7 8 |
# File 'lib/dnif/index.rb', line 6 def conditions @conditions end |
#fields ⇒ Object (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, ) raise "You must specify the attribute type (:integer, :datetime, :date, :boolean, :float)" if [:type].nil? @attributes[name] = [: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 |