Sha256: dfae1729d83873a26c6cad06febdbf4961cd4f439d3d8f8ec8af03b5826a405f
Contents?: true
Size: 1.15 KB
Versions: 7
Compression:
Stored size: 1.15 KB
Contents
require "alephant/renderer/views" require "hashie" require "pathname" module Alephant module Renderer module Views module Base def self.included(base) base.send :include, InstanceMethods base.extend ClassMethods end module InstanceMethods attr_reader :data, :content_type, :base_path def initialize(data = {}) @data = Hashie::Mash.new data @base_path = self.class.base_path setup end def to_h whitelist.reduce({}) do |accum, method_key| accum.tap { |a| a[method_key] = send(method_key) } end end def setup; end def whitelist [] end end module ClassMethods attr_accessor :base_path def inherited(subclass) current_dir = File.dirname(caller.first[/\/[^:]+/]) dir_path = Pathname.new(File.join(current_dir, "..")).realdirpath subclass.base_path = dir_path.to_s Alephant::Renderer::Views.register(subclass) end end end end end end
Version data entries
7 entries across 7 versions & 1 rubygems