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
-
#initialize(name:, key:, value:, size:) ⇒ Attributes
constructor
A new instance of Attributes.
- #name_callable? ⇒ Boolean
- #names(context, table_context) ⇒ Object
- #value_callable? ⇒ Boolean
- #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 15 16 |
# File 'lib/table_structure/schema/columns/attributes.rb', line 9 def initialize(name:, key:, value:, size:) @name_callable = Utils.callable?(name) @name = @name_callable ? name : proc { name } @keys = optimize_size([key].flatten, size) @value_callable = Utils.callable?(value) @value = @value_callable ? value : proc { 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
#name_callable? ⇒ Boolean
28 29 30 |
# File 'lib/table_structure/schema/columns/attributes.rb', line 28 def name_callable? @name_callable end |
#names(context, table_context) ⇒ Object
18 19 20 21 |
# File 'lib/table_structure/schema/columns/attributes.rb', line 18 def names(context, table_context) names = @name.call(context, table_context) optimize_size(names, @size) end |
#value_callable? ⇒ Boolean
32 33 34 |
# File 'lib/table_structure/schema/columns/attributes.rb', line 32 def value_callable? @value_callable end |
#values(context, table_context) ⇒ Object
23 24 25 26 |
# File 'lib/table_structure/schema/columns/attributes.rb', line 23 def values(context, table_context) values = @value.call(context, table_context) optimize_size(values, @size) end |