Sha256: 27ab139333f0ca5677380395655e958c1e30dbf604c706c04348711eafafcf30

Contents?: true

Size: 1.39 KB

Versions: 36

Compression:

Stored size: 1.39 KB

Contents

  module #{element.class_name}AsChild
    def #{element.attribute_name}_child
      accessed
      @#{element.attribute_name}_child
    end

    def #{element.attribute_name}_child=(v)
      accessed
      @#{element.attribute_name}_child = v
    end

    alias #{element.attribute_name} #{element.attribute_name}_child
    alias #{element.attribute_name}= #{element.attribute_name}_child=
  
    def init_#{element.attribute_name}_as_child
      @#{element.attribute_name}_child = []
    end

    def add_#{element.attribute_name}(#{element.attribute_name})
      accessed
      @children << #{element.attribute_name}
      @#{element.attribute_name}_child << #{element.attribute_name}
      #{element.attribute_name}.add_parent(self)
      changed
      return #{element.attribute_name}
    end
  
    def new_#{element.attribute_name}
      accessed
      #{element.attribute_name} = #{element.class_name}.new
      yield(#{element.attribute_name}) if block_given?
      return add_#{element.attribute_name}(#{element.attribute_name})
    end

    def ensure_#{element.attribute_name}
      accessed
      new_#{element.attribute_name} if 0 == #{element.attribute_name}.size
    end

    def remove_#{element.attribute_name}(#{element.attribute_name})
      accessed
      changed
      @#{element.attribute_name}_child.delete(#{element.attribute_name})
      @children.delete(#{element.attribute_name})
    end
  end

Version data entries

36 entries across 36 versions & 3 rubygems

Version Path
hutch-xamplr-1.3.9 lib/xamplr/templates/child.template
xamplr-gen-1.9.16 lib/xamplr-gen/templates/child.template
xamplr-gen-1.9.13 lib/xamplr-gen/templates/child.template
xamplr-gen-1.9.12 lib/xamplr-gen/templates/child.template
xamplr-gen-1.9.11 lib/xamplr-gen/templates/child.template
xamplr-gen-1.9.10 lib/xamplr-gen/templates/child.template
xamplr-gen-1.9.9 lib/xamplr-gen/templates/child.template
xamplr-gen-1.9.8 lib/xamplr-gen/templates/child.template
xamplr-gen-1.9.7 lib/xamplr-gen/templates/child.template
xamplr-gen-1.9.5 lib/xamplr-gen/templates/child.template
xamplr-gen-1.9.4 lib/xamplr-gen/templates/child.template
xamplr-gen-1.9.3 lib/xamplr-gen/templates/child.template
xamplr-gen-1.9.2 lib/xamplr-gen/templates/child.template
xamplr-gen-1.9.0 lib/xamplr-gen/templates/child.template
xamplr-1.3.15 lib/xamplr/templates/child.template
xamplr-1.2.0 lib/xamplr/templates/child.template