Sha256: d501754a30e6e64cb9f663495cb3edd90dc4be79576c6939282a8830440a7796

Contents?: true

Size: 1.08 KB

Versions: 10

Compression:

Stored size: 1.08 KB

Contents

module Faalis
  module Generators
    module Concerns
      # Adds the `name` key to json file which specify the resource name.
      module ResourceName

        private

        # Path to the resource
        def resource_path
          path_parts = resource_data["name"].split("/")
          if path_parts.length > 1
            return "#{path_parts(0..-2).join("/")}/#{path_parts[-1].underscore}"
          end
          resource_data["name"].underscore
        end

        # Url of resource
        def resource_url
          path_parts = resource_data["name"].split("/")
          if path_parts.length > 1
            return "#{path_parts(0..-2).join("/")}/#{path_parts[-1].pluralize.underscore}"
          end
          resource_data["name"].pluralize.underscore
        end

        # Camelized resource name. you can think of it as model name
        def resource
          path_parts = resource_data["name"].split("/")
          if path_parts.length > 1
            return path_parts[-1].camelize
          end
          resource_data["name"].camelize
        end

      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
faalis-2.0.0.rc6 lib/faalis/generators/concerns/resource_name.rb
faalis-2.0.0.rc5 lib/faalis/generators/concerns/resource_name.rb
faalis-2.0.0.rc4 lib/faalis/generators/concerns/resource_name.rb
faalis-2.0.0.rc3 lib/faalis/generators/concerns/resource_name.rb
faalis-2.0.0.rc2 lib/faalis/generators/concerns/resource_name.rb
faalis-1.0.0 lib/faalis/generators/concerns/resource_name.rb
faalis-1.0.0.alpha4 lib/faalis/generators/concerns/resource_name.rb
faalis-1.0.0.alpha3 lib/faalis/generators/concerns/resource_name.rb
faalis-1.0.0.alpha2 lib/faalis/generators/concerns/resource_name.rb
faalis-1.0.0.alpha1 lib/faalis/generators/concerns/resource_name.rb