Sha256: 4f907c788eeafcdfd01ad211808f89e402dab1c0e1eb990ccebdd035df6ec514

Contents?: true

Size: 876 Bytes

Versions: 3

Compression:

Stored size: 876 Bytes

Contents

module Faalis
  module Generators
    module Concerns
      module Parent

        def self.included(base)
          # Specify the parent resource if there was any
          base.class_option :parent, :type => :string, :default => "", :desc => "Specify the parent resource if there was any"
        end

        private

        # check for parent
        def parent?
          if options[:parent] != ""
            return true
          end
          false
        end

        # Remove the starting slash from the given parent path
        def trim_parent_path(path)
          path.gsub(/^\//, "")
        end

        def parents
          if parent?
            _parents = options[:parent].split(",")
            _parents.collect do |p|
              trim_parent_path(p)
            end
          else
            []
          end
        end

      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
faalis-0.19.0 lib/faalis/generators/concerns/parent.rb
faalis-0.18.1 lib/faalis/generators/concerns/parent.rb
faalis-0.18.0 lib/faalis/generators/concerns/parent.rb