Sha256: a1e3c7a16790f804f0023c4cfa0ef59abfda6739e724c496c98aa5c9262d9588

Contents?: true

Size: 587 Bytes

Versions: 4

Compression:

Stored size: 587 Bytes

Contents

module Schematic
  module Generator
    class Names
      attr_accessor :root, :klass

      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.7.1 lib/schematic/generator/names.rb
schematic-0.7.0 lib/schematic/generator/names.rb
schematic-0.6.2 lib/schematic/generator/names.rb
schematic-0.6.1 lib/schematic/generator/names.rb