Sha256: 1bb26db8ce1766ce460bbd51d4b239998bf518b88a64d33533b0fae69f4f37f2
Contents?: true
Size: 1004 Bytes
Versions: 7
Compression:
Stored size: 1004 Bytes
Contents
module Nagoro class Element attr_accessor :content, :params def initialize(content) @content = content.strip end def render @content end def params=(params = {}) params.each_pair do |key, value| instance_variable_set("@#{key}", value) end end def self.inherited(klass) Nagoro::Pipe::Element::ELEMENTS[klass.to_s] = klass end end # FileElement puts created elements into this module module GeneratedElement end def self.FileElement(file) element = Class.new(Element){ define_method(:element_file){ file } def render main = File.read(element_file) @delim = "T" << rand(8 << 100).to_s eval(%{<<#@delim\n#{main}\n#@delim}) end } name = File.basename(file, File.extname(file)) GeneratedElement::const_set(name, element) Pipe::Element::ELEMENTS.delete_if{|k,v| v == element} Pipe::Element::ELEMENTS[name] = element element end end
Version data entries
7 entries across 7 versions & 2 rubygems