Sha256: 50f52875af31bf027ecb567fe4b0bc6555a9af0ac3165b5a98d3787f49025c31

Contents?: true

Size: 844 Bytes

Versions: 1

Compression:

Stored size: 844 Bytes

Contents

module Flutterby
  class Folder < Entity
    def read
      Dir[::File.join(fs_path, "*")].each do |entry|
        if entity = Flutterby.from(entry)
          children << entity
        end
      end
    end

    def write_static(path)
      Dir.mkdir(path) unless ::File.exists?(path)

      children.each do |child|
        child.export(path)
      end
    end

    def extend_view!(view)
      # Load the view extension available in this folder into the given view.
      #
      if view_entity = find("_view.rb")
        case view_entity.ext
        when "rb" then
          view.instance_eval(view_entity.contents)
        else
          raise "Unknown view extension #{view_entity.full_name}"
        end
      end

      # Then pass the whole thing up the stack.
      #
      parent ? parent.extend_view!(view) : view
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
flutterby-0.0.8 lib/flutterby/folder.rb