Sha256: 9501c8542b6bbce9917ee5fbd303aa562e1cfeb438f2c2ddeb2be05fc6dcc01e

Contents?: true

Size: 856 Bytes

Versions: 1

Compression:

Stored size: 856 Bytes

Contents

module Vedeu
  module API
    InterfaceNotSpecified = Class.new(StandardError)

    class View
      def self.build(name, &block)
        new(name).build(&block)
      end

      def initialize(name)
        fail InterfaceNotSpecified if name.nil? || name.empty?

        @name = name.to_s
      end

      def build(&block)
        @self_before_instance_eval = eval('self', block.binding)

        instance_eval(&block) if block_given?

        attributes
      end

      def line(&block)
        attributes[:lines] << Line.build(&block)
      end

      def attributes
        @_attributes ||= { name: name, lines: [] }
      end

      def name
        return @name if Store.query(@name)
      end

      private

      def method_missing(method, *args, &block)
        @self_before_instance_eval.send method, *args, &block
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vedeu-0.1.10 lib/vedeu/api/view.rb