lib/pg_serializable/nodes/attribute.rb in pg_serializable-0.1.1 vs lib/pg_serializable/nodes/attribute.rb in pg_serializable-1.0.0

- old
+ new

@@ -1,25 +1,14 @@ module PgSerializable module Nodes class Attribute < Base - def initialize(column_name, label: nil, &prc) + attr_reader :column_name, :klass, :label, :prc + + def initialize(klass, column_name, label: nil, &prc) + @klass = klass @column_name = column_name @label = label || column_name @prc = prc if block_given? - end - - def to_sql(table_alias=nil) - [key, value(table_alias)].join(',') - end - - private - def key - "\'#{@label}\'" - end - - def value(tbl) - val = "#{tbl && "#{tbl}."}#{@column_name}" - @prc ? @prc.call(val) : val end end end end