Class: TableStructure::Schema::Columns::Attributes
- Inherits:
-
Object
- Object
- TableStructure::Schema::Columns::Attributes
- Defined in:
- lib/table_structure/schema/columns/attributes.rb
Instance Attribute Summary collapse
-
#keys ⇒ Object
readonly
Returns the value of attribute keys.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
Instance Method Summary collapse
- #contain_callable?(attribute) ⇒ Boolean
-
#initialize(name:, key:, value:, size:) ⇒ Attributes
constructor
A new instance of Attributes.
- #names(context, table_context) ⇒ Object
- #values(context, table_context) ⇒ Object
Constructor Details
#initialize(name:, key:, value:, size:) ⇒ Attributes
Returns a new instance of Attributes.
9 10 11 12 13 14 |
# File 'lib/table_structure/schema/columns/attributes.rb', line 9 def initialize(name:, key:, value:, size:) @name = name @keys = optimize_size([key].flatten, size) @value = value @size = size end |
Instance Attribute Details
#keys ⇒ Object (readonly)
Returns the value of attribute keys.
7 8 9 |
# File 'lib/table_structure/schema/columns/attributes.rb', line 7 def keys @keys end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
7 8 9 |
# File 'lib/table_structure/schema/columns/attributes.rb', line 7 def size @size end |
Instance Method Details
#contain_callable?(attribute) ⇒ Boolean
26 27 28 29 |
# File 'lib/table_structure/schema/columns/attributes.rb', line 26 def contain_callable?(attribute) val = instance_variable_get("@#{attribute}") Utils.callable?(val) end |
#names(context, table_context) ⇒ Object
16 17 18 19 |
# File 'lib/table_structure/schema/columns/attributes.rb', line 16 def names(context, table_context) name = Utils.evaluate_callable(@name, context, table_context) optimize_size(name, @size) end |
#values(context, table_context) ⇒ Object
21 22 23 24 |
# File 'lib/table_structure/schema/columns/attributes.rb', line 21 def values(context, table_context) value = Utils.evaluate_callable(@value, context, table_context) optimize_size(value, @size) end |