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.0.0 lib/xamplr/templates/child.template
hutch-xamplr-1.0.1 lib/xamplr/templates/child.template
hutch-xamplr-1.0.2 lib/xamplr/templates/child.template
hutch-xamplr-1.0.3 lib/xamplr/templates/child.template
hutch-xamplr-1.0.4 lib/xamplr/templates/child.template
hutch-xamplr-1.0.5 lib/xamplr/templates/child.template
hutch-xamplr-1.1.0 lib/xamplr/templates/child.template
hutch-xamplr-1.1.1 lib/xamplr/templates/child.template
hutch-xamplr-1.1.2 lib/xamplr/templates/child.template
hutch-xamplr-1.1.4 lib/xamplr/templates/child.template
hutch-xamplr-1.2.0 lib/xamplr/templates/child.template
hutch-xamplr-1.3.0 lib/xamplr/templates/child.template
hutch-xamplr-1.3.1 lib/xamplr/templates/child.template
hutch-xamplr-1.3.10 lib/xamplr/templates/child.template
hutch-xamplr-1.3.11 lib/xamplr/templates/child.template
hutch-xamplr-1.3.12 lib/xamplr/templates/child.template
hutch-xamplr-1.3.13 lib/xamplr/templates/child.template
hutch-xamplr-1.3.14 lib/xamplr/templates/child.template
hutch-xamplr-1.3.3 lib/xamplr/templates/child.template
hutch-xamplr-1.3.8 lib/xamplr/templates/child.template