Class: N::Property

Inherits:
Object show all
Defined in:
lib/glue/property.rb

Overview

Ruby attributes are typeless and generally this is good. Some times we need extra metadata though, for example in relational mapping, or web form population.

Only Fixnums, Strings, Floats, Times, Booleans are converted.

The default = methods do not force the types. A special __force_set method should be used instead. – TODO: Perhaps a sync is needed in evals (!!!!) ++

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(symbol, klass, meta = {}) ⇒ Property

Returns a new instance of Property.



49
50
51
52
53
# File 'lib/glue/property.rb', line 49

def initialize(symbol, klass, meta = {})
	@symbol, @klass = symbol, klass
	@meta = meta
	@name = @symbol.to_s()
end

Instance Attribute Details

#klassObject

the class of the property



43
44
45
# File 'lib/glue/property.rb', line 43

def klass
  @klass
end

#metaObject

additional metadata (like sql declaration, sql index, etc)



47
48
49
# File 'lib/glue/property.rb', line 47

def meta
  @meta
end

#nameObject

the string representation of the symbol



39
40
41
# File 'lib/glue/property.rb', line 39

def name
  @name
end

#symbolObject

the symbol of the property



35
36
37
# File 'lib/glue/property.rb', line 35

def symbol
  @symbol
end

Instance Method Details

#==(other) ⇒ Object



55
56
57
# File 'lib/glue/property.rb', line 55

def ==(other)
	return @symbol == other.symbol
end

#to_sObject



59
60
61
# File 'lib/glue/property.rb', line 59

def to_s
	return name
end