Class: Stepford::ColumnRepresentation
- Inherits:
-
Object
- Object
- Stepford::ColumnRepresentation
- Defined in:
- lib/stepford/column_representation.rb
Overview
Needed a column representation that would allow user to specify attributes that are used for sample data choice for virtual attributes e.g. if you have an object_id column in the schema, but in model you have virtual proxy attribute methods to set it like my_object_id/my_object_id= then you need a way to specify that it should set my_object_id= with a string vs. number, etc.
Instance Attribute Summary collapse
-
#default ⇒ Object
Returns the value of attribute default.
-
#limit ⇒ Object
Returns the value of attribute limit.
-
#name ⇒ Object
Returns the value of attribute name.
-
#null ⇒ Object
Returns the value of attribute null.
-
#precision ⇒ Object
Returns the value of attribute precision.
-
#scale ⇒ Object
Returns the value of attribute scale.
-
#type ⇒ Object
Returns the value of attribute type.
-
#virtual ⇒ Object
Returns the value of attribute virtual.
Instance Method Summary collapse
-
#initialize(args) ⇒ ColumnRepresentation
constructor
A new instance of ColumnRepresentation.
- #merge_options(options) ⇒ Object
Constructor Details
#initialize(args) ⇒ ColumnRepresentation
Returns a new instance of ColumnRepresentation.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/stepford/column_representation.rb', line 8 def initialize(args) if args.is_a?(Symbol) @name = args.to_sym elsif !(args.nil?) # assume initializing with column # see: http://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/TableDefinition.html#method-i-column @name = args.name @type = args.type @limit = args.limit @default = args.default @null = args.null # should be called nullable, but using what Rails/AR calls it to be easier to work with as if were a "real" AR column @precision = args.precision @scale = args.scale end end |
Instance Attribute Details
#default ⇒ Object
Returns the value of attribute default.
6 7 8 |
# File 'lib/stepford/column_representation.rb', line 6 def default @default end |
#limit ⇒ Object
Returns the value of attribute limit.
6 7 8 |
# File 'lib/stepford/column_representation.rb', line 6 def limit @limit end |
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/stepford/column_representation.rb', line 6 def name @name end |
#null ⇒ Object
Returns the value of attribute null.
6 7 8 |
# File 'lib/stepford/column_representation.rb', line 6 def null @null end |
#precision ⇒ Object
Returns the value of attribute precision.
6 7 8 |
# File 'lib/stepford/column_representation.rb', line 6 def precision @precision end |
#scale ⇒ Object
Returns the value of attribute scale.
6 7 8 |
# File 'lib/stepford/column_representation.rb', line 6 def scale @scale end |
#type ⇒ Object
Returns the value of attribute type.
6 7 8 |
# File 'lib/stepford/column_representation.rb', line 6 def type @type end |
#virtual ⇒ Object
Returns the value of attribute virtual.
6 7 8 |
# File 'lib/stepford/column_representation.rb', line 6 def virtual @virtual end |
Instance Method Details
#merge_options(options) ⇒ Object
24 25 26 |
# File 'lib/stepford/column_representation.rb', line 24 def () .each {|k,v|instance_variable_set("@#{k}", v)} end |