Class: CanPlay::AbstractResource

Inherits:
Object
  • Object
show all
Extended by:
ClassMethods
Includes:
RorHack::ClassLevelInheritableAttributes
Defined in:
lib/can_play/resource.rb

Direct Known Subclasses

Resource, ResourceOverride

Defined Under Namespace

Classes: OnlyInstance

Class Method Summary collapse

Methods included from ClassMethods

add_resource, collection, group, limit, member

Class Method Details

.inherited(base) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/can_play/resource.rb', line 19

def self.inherited(base)
  super
  base.class_eval do
    # 定义动态类。
    base.const_set "OnlyInstance", Class.new(self::OnlyInstance)
  end
end

.set_method(name, &block) ⇒ Object



13
14
15
16
17
# File 'lib/can_play/resource.rb', line 13

def self.set_method(name, &block)
  self::OnlyInstance.after_initialize_block_array << Proc.new do
    define_singleton_method name, &block
  end
end

.set_module_name(str) ⇒ Object



9
10
11
# File 'lib/can_play/resource.rb', line 9

def self.set_module_name(str)
  self.my_module_name = str
end