Class: LazyRecords::Definition
- Inherits:
-
Object
- Object
- LazyRecords::Definition
- Defined in:
- lib/definition.rb
Instance Attribute Summary collapse
-
#columns ⇒ Object
readonly
Returns the value of attribute columns.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #add_exclusions ⇒ Object
- #add_exclusions=(*values) ⇒ Object
- #columns_as_list ⇒ Object
-
#initialize(name, *columns) ⇒ Definition
constructor
A new instance of Definition.
- #suggest_keywords(connection) ⇒ Object
Constructor Details
#initialize(name, *columns) ⇒ Definition
Returns a new instance of Definition.
11 12 13 14 15 16 17 |
# File 'lib/definition.rb', line 11 def initialize(name, *columns) @name = name @columns = columns @client = none @add_exclusions = none @show_sql = false end |
Instance Attribute Details
#columns ⇒ Object (readonly)
Returns the value of attribute columns.
9 10 11 |
# File 'lib/definition.rb', line 9 def columns @columns end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
9 10 11 |
# File 'lib/definition.rb', line 9 def name @name end |
Instance Method Details
#add_exclusions ⇒ Object
27 28 29 |
# File 'lib/definition.rb', line 27 def add_exclusions option(@add_exclusions) end |
#add_exclusions=(*values) ⇒ Object
23 24 25 |
# File 'lib/definition.rb', line 23 def add_exclusions=(*values) @add_exclusions = sequence(values.flatten) end |
#columns_as_list ⇒ Object
19 20 21 |
# File 'lib/definition.rb', line 19 def columns_as_list columns.first.map(&:name) end |
#suggest_keywords(connection) ⇒ Object
31 32 33 34 35 36 |
# File 'lib/definition.rb', line 31 def suggest_keywords(connection) fields = connection.fields(@name) keywords = fields.map { |field| "#{field} = keyword(:#{field})" }.join("\n") puts keywords puts "#{@name} = definition(:#{@name}, #{fields.join(', ')})" end |