Sha256: 1c67cb7ea76174d29f416776193c7489da3a310ecd8f13b0d6b70de2deeadb4d

Contents?: true

Size: 1.43 KB

Versions: 12

Compression:

Stored size: 1.43 KB

Contents

module PowerStencil
  module Dsl

    module Entities

      def available_entity_types(force_rescan: false)
        PowerStencil.project.engine.available_entity_types force_rescan: force_rescan
      end

      def build_target
        type, name = main_entry_point.split('/')
        e = entity type, name
        e.nil? ? entity(type.to_sym, name) : e
      end

      def entity(type, name)
        PowerStencil.project.engine.entity type, name, @universe
      end

      def entities(criterion: nil, value: nil, &filter_block)
        PowerStencil.project.engine.entities @universe, criterion: criterion, value: value, &filter_block
      end

      def delete_entity(entity, delete_files: false)
        PowerStencil.project.engine.delete_entity @universe, entity.type, entity.name, delete_files: delete_files
      end

      def method_missing(method_name, *arguments, &block)
        if method_name.to_s =~ /^user_new_(.*)/
          PowerStencil.project.engine.new_entity @universe, $1, fields: Hash[*arguments], user: true, &block
        elsif method_name.to_s =~ /^new_(.*)$/
          PowerStencil.project.engine.new_entity @universe, $1, fields: Hash[*arguments], &block
        else
          PowerStencil.logger.warn "Invalid DSL method: '#{method_name}'"
          super
        end
      end

      def respond_to_missing?(method_name, include_private = false)
        method_name.to_s.start_with?('new_') || super
      end

    end

  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
power_stencil-0.4.1 lib/power_stencil/dsl/entities.rb
power_stencil-0.4.0 lib/power_stencil/dsl/entities.rb
power_stencil-0.3.9 lib/power_stencil/dsl/entities.rb
power_stencil-0.3.8 lib/power_stencil/dsl/entities.rb
power_stencil-0.3.7 lib/power_stencil/dsl/entities.rb
power_stencil-0.3.6 lib/power_stencil/dsl/entities.rb
power_stencil-0.3.5 lib/power_stencil/dsl/entities.rb
power_stencil-0.3.4 lib/power_stencil/dsl/entities.rb
power_stencil-0.3.3 lib/power_stencil/dsl/entities.rb
power_stencil-0.3.2 lib/power_stencil/dsl/entities.rb
power_stencil-0.3.1 lib/power_stencil/dsl/entities.rb
power_stencil-0.3.0 lib/power_stencil/dsl/entities.rb