Sha256: e89d207b8c7fd9fdaed20f7f93b694ddeaa77bab23311d3f9ae3476c195c18ab
Contents?: true
Size: 1.2 KB
Versions: 3
Compression:
Stored size: 1.2 KB
Contents
require 'sham/shammable' require 'sham/config/assign' require 'sham/config/attributes' require 'sham/config/parameters' require 'sham/config/empty' require 'sham/config/no_args' module Sham class << self def config klass, name = :default unless (class << klass; self; end).include?(Sham::Shammable) klass.extend(Sham::Shammable) end yield(Sham::Config.new(klass, name)) if block_given? end end class Config def self.activate! root = nil root = Rails.root if root.nil? && defined?(Rails.root) root = File.join(root, 'sham', '**', '*.rb') Dir[root].each{ |f| load(f) } end def initialize klass, name @klass = klass @name = name end def assign(&config) @klass.add_sham_config(@name, Sham::Config::Assign.new(config)) end def attributes(&config) @klass.add_sham_config(@name, Sham::Config::Attributes.new(config)) end def parameters(&config) @klass.add_sham_config(@name, Sham::Config::Parameters.new(config)) end def empty @klass.add_sham_config(@name, Sham::Config::Empty.new) end def no_args @klass.add_sham_config(@name, Sham::Config::NoArgs.new) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
sham-2.0.0 | lib/sham/config.rb |
sham-1.2.0 | lib/sham/config.rb |
sham-1.1.0 | lib/sham/config.rb |