Sha256: d54c2fc40c298c614fcfcc155980f5d406361bfb3c8db2ad075fd2a4cb6e70ee
Contents?: true
Size: 949 Bytes
Versions: 2
Compression:
Stored size: 949 Bytes
Contents
require 'alephant/publisher/views' require 'json' require 'hashie' module Alephant::Publisher::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({}) { |m,s| m.tap { |m| m[s] = self.send(s) } } 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::Publisher::Views.register(subclass) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
alephant-publisher-0.6.3 | lib/alephant/publisher/views/base.rb |
alephant-publisher-0.6.2 | lib/alephant/publisher/views/base.rb |