Class: RightAws::ActiveSdb::ColumnSet

Inherits:
Object
  • Object
show all
Defined in:
lib/sdb/active_sdb.rb

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (ColumnSet) initialize



1055
1056
1057
# File 'lib/sdb/active_sdb.rb', line 1055

def initialize
  @columns = {}
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

- (Object) method_missing(method_sym, *args)



1078
1079
1080
1081
1082
# File 'lib/sdb/active_sdb.rb', line 1078

def method_missing(method_sym, *args)
  data_type = args.shift || :String
  options = args.shift || {}
  @columns[method_sym.to_s] = options.merge( :type => data_type )
end

Instance Attribute Details

- (Object) columns

Returns the value of attribute columns



1054
1055
1056
# File 'lib/sdb/active_sdb.rb', line 1054

def columns
  @columns
end

Instance Method Details

- (Object) all



1059
1060
1061
# File 'lib/sdb/active_sdb.rb', line 1059

def all
  @columns.keys
end

- (Object) column(col_name) Also known as: include?



1063
1064
1065
# File 'lib/sdb/active_sdb.rb', line 1063

def column(col_name)
  @columns[col_name.to_s]
end

- (Object) default(col_name)



1072
1073
1074
1075
1076
# File 'lib/sdb/active_sdb.rb', line 1072

def default(col_name)
  return nil unless include?(col_name)
  default = column(col_name)[:default]
  default.respond_to?(:call) ? default.call : default
end

- (Object) type_of(col_name)



1068
1069
1070
# File 'lib/sdb/active_sdb.rb', line 1068

def type_of(col_name)
  column(col_name) && column(col_name)[:type]
end