Class: PgSerializable::Nodes::Attribute

Inherits:
Base
  • Object
show all
Defined in:
lib/pg_serializable/nodes/attribute.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#to_s

Constructor Details

#initialize(klass, column_name, label: nil, &prc) ⇒ Attribute

Returns a new instance of Attribute.



6
7
8
9
10
11
# File 'lib/pg_serializable/nodes/attribute.rb', line 6

def initialize(klass, column_name, label: nil, &prc)
  @klass = klass
  @column_name = column_name
  @label = label || column_name
  @prc = prc if block_given?
end

Instance Attribute Details

#column_nameObject (readonly)

Returns the value of attribute column_name.



4
5
6
# File 'lib/pg_serializable/nodes/attribute.rb', line 4

def column_name
  @column_name
end

#klassObject (readonly)

Returns the value of attribute klass.



4
5
6
# File 'lib/pg_serializable/nodes/attribute.rb', line 4

def klass
  @klass
end

#labelObject (readonly)

Returns the value of attribute label.



4
5
6
# File 'lib/pg_serializable/nodes/attribute.rb', line 4

def label
  @label
end

#prcObject (readonly)

Returns the value of attribute prc.



4
5
6
# File 'lib/pg_serializable/nodes/attribute.rb', line 4

def prc
  @prc
end

Instance Method Details

#enum?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/pg_serializable/nodes/attribute.rb', line 13

def enum?
  @enum ||= klass.defined_enums.has_key? column_name.to_s
end