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

#initializeColumnSet

Returns a new instance of ColumnSet.



1040
1041
1042
# File 'lib/sdb/active_sdb.rb', line 1040

def initialize
  @columns = {}
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_sym, *args) ⇒ Object



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

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

#columnsObject

Returns the value of attribute columns.



1039
1040
1041
# File 'lib/sdb/active_sdb.rb', line 1039

def columns
  @columns
end

Instance Method Details

#allObject



1044
1045
1046
# File 'lib/sdb/active_sdb.rb', line 1044

def all
  @columns.keys
end

#column(col_name) ⇒ Object Also known as: include?



1048
1049
1050
# File 'lib/sdb/active_sdb.rb', line 1048

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

#default(col_name) ⇒ Object



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

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

#type_of(col_name) ⇒ Object



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

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