Class: XDry::Generators::PropertyFromField

Inherits:
Generator
  • Object
show all
Defined in:
lib/xdry/generators/property-from-field.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
17
18
# File 'lib/xdry/generators/property-from-field.rb', line 8

def process_attribute oclass, oattr
  if !oattr.has_property_def? && oattr.wants_property? && oattr.type_known?
    pd = oattr.new_property_def

    ip = BeforeInterfaceEndIP.new(oclass)
    lines = Emitter.capture do |o|
      o << pd.to_source
    end
    ip.insert patcher, [""] + lines + [""]
  end
end