Class: ActiveGroonga::Vector
- Inherits:
-
Object
- Object
- ActiveGroonga::Vector
- Includes:
- Enumerable
- Defined in:
- lib/active_groonga/vector.rb
Instance Attribute Summary (collapse)
-
- (Object) klass
readonly
Returns the value of attribute klass.
-
- (Object) owner
readonly
Returns the value of attribute owner.
-
- (Object) values
readonly
Returns the value of attribute values.
Instance Method Summary (collapse)
- - (Object) <<(value)
- - (Object) build(*args, &block)
- - (Object) create(*args, &block)
- - (Object) create!(*args, &block)
- - (Object) each
-
- (Vector) initialize(owner, klass, values = [])
constructor
A new instance of Vector.
- - (Object) to_ary
Constructor Details
- (Vector) initialize(owner, klass, values = [])
Returns a new instance of Vector
21 22 23 24 25 26 |
# File 'lib/active_groonga/vector.rb', line 21 def initialize(owner, klass, values=[]) @owner = owner @klass = klass @values = values @values = [@values] unless @values.is_a?(Array) end |
Instance Attribute Details
- (Object) klass (readonly)
Returns the value of attribute klass
20 21 22 |
# File 'lib/active_groonga/vector.rb', line 20 def klass @klass end |
- (Object) owner (readonly)
Returns the value of attribute owner
20 21 22 |
# File 'lib/active_groonga/vector.rb', line 20 def owner @owner end |
- (Object) values (readonly)
Returns the value of attribute values
20 21 22 |
# File 'lib/active_groonga/vector.rb', line 20 def values @values end |
Instance Method Details
- (Object) <<(value)
46 47 48 49 |
# File 'lib/active_groonga/vector.rb', line 46 def <<(value) value = @klass.create(value) if @owner.persisted? @values << value end |
- (Object) build(*args, &block)
28 29 30 |
# File 'lib/active_groonga/vector.rb', line 28 def build(*args, &block) @klass.new(*args, &block) end |
- (Object) create(*args, &block)
32 33 34 |
# File 'lib/active_groonga/vector.rb', line 32 def create(*args, &block) @klass.create(*args, &block) end |
- (Object) create!(*args, &block)
36 37 38 |
# File 'lib/active_groonga/vector.rb', line 36 def create!(*args, &block) @klass.create!(*args, &block) end |
- (Object) each
40 41 42 43 44 |
# File 'lib/active_groonga/vector.rb', line 40 def each @values.each do |value| yield(instantiate(value)) end end |
- (Object) to_ary
51 52 53 |
# File 'lib/active_groonga/vector.rb', line 51 def to_ary to_a end |