Sha256: f9b2b0524177390ccbe2fc2e3c1a33292624f4695df5653becd37d4e405feff7
Contents?: true
Size: 1.01 KB
Versions: 4
Compression:
Stored size: 1.01 KB
Contents
require File.expand_path('../structure', __FILE__) module ExtendModelAt class Environment def initialize @config = {} @config[:has_one] = {} @config[:has_many] = {} @config[:belongs_to] = {} @config[:static] = false end def run(env=nil, model=nil) instance_exec env end [:has_one, :has_many, :belongs_to].each do |function| define_method(function.to_s) do |name, opts={}| @config[function][name.to_sym] = opts end end # == Defining columns # You cand define the _table structure_ using the function +structure+ # # structure :static => true do |t| # t.string :name # t.integer :loggin_counter, :default => 0 # t.belongs_to :account # t.belongs_to :owner, :polymorphic => true # end def structure(options={}) @config[:columns] = Structure.new.run yield @config[:static] = options[:static] end protected def config @config end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
extend_at-0.2.4 | lib/extend_at/environment.rb |
extend_at-0.2.3 | lib/extend_at/environment.rb |
extend_at-0.2.2 | lib/extend_at/environment.rb |
extend_at-0.2.1 | lib/extend_at/environment.rb |