Class: XDry::Generators::FieldFromProperty

Inherits:
Generator
  • Object
show all
Defined in:
lib/xdry/generators/field_from_property.rb

Instance Attribute Summary

Attributes inherited from Generator

#patcher

Instance Method Summary collapse

Methods inherited from Generator

id, inherited, #initialize, #process_class, #verbose?

Constructor Details

This class inherits a constructor from XDry::Generators::Generator

Instance Method Details

#process_attribute(oclass, oattr) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'lib/xdry/generators/field_from_property.rb', line 8

def process_attribute oclass, oattr
  if !oattr.has_field_def? && oattr.type_known? && !oclass.has_method_impl?(oattr.getter_selector)
    lines = [oattr.new_field_def.to_source]
    if oclass.main_interface # && oclass.main_interface.fields_scope
      node = oclass.main_interface.fields_scope.end_node
      patcher.insert_before node.pos, lines, node.indent + INDENT_STEP
    end
  end
end