Ai
1 Star 0 Fork 0

g1a22/mirror-gitlab-org-gitlab-ce

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
static_model.rb 775 Bytes
一键复制 编辑 原始数据 按行查看 历史
Dmitriy Zaporozhets 提交于 2013-01-05 06:35 +08:00 . Fixed styles, ProjectHook specs etc
# Provides an ActiveRecord-like interface to a model whose data is not persisted to a database.
module StaticModel
extend ActiveSupport::Concern
module ClassMethods
# Used by ActiveRecord's polymorphic association to set object_id
def primary_key
'id'
end
# Used by ActiveRecord's polymorphic association to set object_type
def base_class
self
end
end
# Used by AR for fetching attributes
#
# Pass it along if we respond to it.
def [](key)
send(key) if respond_to?(key)
end
def to_param
id
end
def new_record?
false
end
def persisted?
false
end
def destroyed?
false
end
def ==(other)
if other.is_a? ::StaticModel
id == other.id
else
super
end
end
end
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/gyiang/mirror-gitlab-org-gitlab-ce.git
git@gitee.com:gyiang/mirror-gitlab-org-gitlab-ce.git
gyiang
mirror-gitlab-org-gitlab-ce
mirror-gitlab-org-gitlab-ce
master

搜索帮助