Class: Goedel::Statement
- Inherits:
-
Object
- Object
- Goedel::Statement
- Defined in:
- lib/goedel/statement.rb
Instance Attribute Summary collapse
-
#force_attributes ⇒ Object
readonly
Returns the value of attribute force_attributes.
-
#indent ⇒ Object
readonly
Returns the value of attribute indent.
-
#object ⇒ Object
readonly
Returns the value of attribute object.
-
#override_attributes ⇒ Object
readonly
Returns the value of attribute override_attributes.
Instance Method Summary collapse
- #generate ⇒ Object
-
#initialize(object, options = {}) ⇒ Statement
constructor
A new instance of Statement.
Constructor Details
#initialize(object, options = {}) ⇒ Statement
Returns a new instance of Statement.
5 6 7 8 9 10 |
# File 'lib/goedel/statement.rb', line 5 def initialize(object, ={}) @object = object @force_attributes = [:force_attributes] || [] @override_attributes = [:override_attributes] || {} @indent = 2 end |
Instance Attribute Details
#force_attributes ⇒ Object (readonly)
Returns the value of attribute force_attributes.
3 4 5 |
# File 'lib/goedel/statement.rb', line 3 def force_attributes @force_attributes end |
#indent ⇒ Object (readonly)
Returns the value of attribute indent.
3 4 5 |
# File 'lib/goedel/statement.rb', line 3 def indent @indent end |
#object ⇒ Object (readonly)
Returns the value of attribute object.
3 4 5 |
# File 'lib/goedel/statement.rb', line 3 def object @object end |
#override_attributes ⇒ Object (readonly)
Returns the value of attribute override_attributes.
3 4 5 |
# File 'lib/goedel/statement.rb', line 3 def override_attributes @override_attributes end |
Instance Method Details
#generate ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/goedel/statement.rb', line 12 def generate output_array = [model_instantiate] model_attributes.each do |prop, val| next unless val output_array << "#{" "*indent}#{attr_line(prop, val)}" end output_array << "#{instance_name}.save" output_array.join("\n") end |