Class: Goedel::Statement

Inherits:
Object
  • Object
show all
Defined in:
lib/goedel/statement.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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, options={})
  @object = object
  @force_attributes = options[:force_attributes] || []
  @override_attributes = options[:override_attributes] || {}
  @indent = 2
end

Instance Attribute Details

#force_attributesObject (readonly)

Returns the value of attribute force_attributes.



3
4
5
# File 'lib/goedel/statement.rb', line 3

def force_attributes
  @force_attributes
end

#indentObject (readonly)

Returns the value of attribute indent.



3
4
5
# File 'lib/goedel/statement.rb', line 3

def indent
  @indent
end

#objectObject (readonly)

Returns the value of attribute object.



3
4
5
# File 'lib/goedel/statement.rb', line 3

def object
  @object
end

#override_attributesObject (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

#generateObject



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