Class: Linkage::Group
- Inherits:
-
Object
- Object
- Linkage::Group
- Includes:
- Decollation
- Defined in:
- lib/linkage/group.rb
Instance Attribute Summary collapse
-
#count ⇒ Integer
readonly
Number of records in this group.
-
#id ⇒ Integer
readonly
This group’s ID (if it exists).
-
#values ⇒ Hash
readonly
Hash of matching values.
Class Method Summary collapse
Instance Method Summary collapse
- #decollated_values ⇒ Object
-
#initialize(values, options) ⇒ Group
constructor
A new instance of Group.
Methods included from Decollation
#decollate, #decollate_mysql, #decollate_mysql_latin1_swedish_ci
Constructor Details
#initialize(values, options) ⇒ Group
Returns a new instance of Group.
35 36 37 38 39 40 41 |
# File 'lib/linkage/group.rb', line 35 def initialize(values, ) @count = [:count] @id = [:id] @ruby_types = [:ruby_types] @database_type = [:database_type] @values = values end |
Instance Attribute Details
#count ⇒ Integer (readonly)
Returns Number of records in this group.
9 10 11 |
# File 'lib/linkage/group.rb', line 9 def count @count end |
#id ⇒ Integer (readonly)
Returns This group’s ID (if it exists).
12 13 14 |
# File 'lib/linkage/group.rb', line 12 def id @id end |
#values ⇒ Hash (readonly)
Returns Hash of matching values.
6 7 8 |
# File 'lib/linkage/group.rb', line 6 def values @values end |
Class Method Details
.from_row(row) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/linkage/group.rb', line 14 def self.from_row(row) values = {} = {} row.each_pair do |key, value| if key == :id || key == :count [key] = value else values[key] = value end end new(values, ) end |
Instance Method Details
#decollated_values ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/linkage/group.rb', line 43 def decollated_values @values.inject({}) do |hsh, (key, value)| ruby_type = @ruby_types[key] if ruby_type && ruby_type.has_key?(:opts) && ruby_type[:opts].has_key?(:collate) hsh[key] = decollate(value, @database_type, ruby_type[:opts][:collate]) else hsh[key] = value end hsh end end |