Sha256: 267747028b0b4e5a615a62c93434f565f61a31161fe540304abc9b7f4529681b

Contents?: true

Size: 579 Bytes

Versions: 4

Compression:

Stored size: 579 Bytes

Contents

module Schematic
  module Generator
    class Names
      attr_accessor :root

      def initialize(klass)
        @klass = klass
      end

      def type
        @klass.name.gsub(/::/,'')
      end

      def element
        element_name
      end

      def element_collection
        element_name.pluralize
      end

      def collection_type
        type.pluralize
      end

      def nested_attribute_name
        "#{element_collection}-attributes"
      end

      private

      def element_name
        (@root || type.underscore).dasherize
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
schematic-0.6.0 lib/schematic/generator/names.rb
schematic-0.5.9 lib/schematic/generator/names.rb
schematic-0.5.8 lib/schematic/generator/names.rb
schematic-0.5.7 lib/schematic/generator/names.rb