Sha256: 25aea7a9a99ce08561c28b73b5d402f5e0e63ce3c7b0be9c22d1284f7c948fb7
Contents?: true
Size: 1.63 KB
Versions: 3
Compression:
Stored size: 1.63 KB
Contents
require 'clevic/view.rb' require 'clevic/default_view.rb' module Clevic # include this in Sequel::Model classes to # get embedded view definitions. See ModelBuilder. # # A Clevic::Default#{model}View class will be created. If # a define_ui block is not specified in the entity class, # a default UI will be created. module Record module ClassMethods def default_view_class_name "::Clevic::Default#{name.gsub('::','')}View" end def create_view_class # create the default view class # Don't use Class.new because even if you assign # the result to a constant, there are still anonymous classes # hanging around, which gives weird results with Clevic::View.subclasses. st,line = <<-EOF, __LINE__ class #{default_view_class_name} < Clevic::DefaultView entity_class #{name} end EOF eval st, nil, __FILE__, line # keep track of the order in which views are # defined, so that can be used as the default ordering # of the views. Clevic::View.order << default_view_class_name.constantize end def default_view_class @default_view_class ||= eval default_view_class_name end # Need to defer the execution of the view definition block # until related models have been defined. def define_ui( &block ) default_view_class.define_ui_block( &block ) end end def self.included( base ) base.extend( ClassMethods ) # create the default view class base.create_view_class end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
clevic-0.13.0.b3 | lib/clevic/record.rb |
clevic-0.13.0.b2 | lib/clevic/record.rb |
clevic-0.13.0.b1 | lib/clevic/record.rb |