Module: CFoundry::V2::ModelMagic
- Includes:
- Attribute, ClientExtensions, HasSummary, QueryableBy, ToMany, ToOne
- Included in:
- Model
- Defined in:
- lib/cfoundry/v2/model_magic.rb,
lib/cfoundry/v2/model_magic/to_one.rb,
lib/cfoundry/v2/model_magic/to_many.rb,
lib/cfoundry/v2/model_magic/attribute.rb,
lib/cfoundry/v2/model_magic/has_summary.rb,
lib/cfoundry/v2/model_magic/client_extensions.rb
Defined Under Namespace
Modules: Attribute, ClientExtensions, HasSummary, QueryableBy, ToMany, ToOne
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
#queryable_by
Methods included from ToMany
#to_many
Methods included from ToOne
#to_one
Methods included from Attribute
#attribute
Methods included from HasSummary
#has_summary
#add_client_methods
Instance Attribute Details
#scoped_organization ⇒ Object
Returns the value of attribute scoped_organization.
31
32
33
|
# File 'lib/cfoundry/v2/model_magic.rb', line 31
def scoped_organization
@scoped_organization
end
|
#scoped_space ⇒ Object
Returns the value of attribute scoped_space.
31
32
33
|
# File 'lib/cfoundry/v2/model_magic.rb', line 31
def scoped_space
@scoped_space
end
|
Class Method Details
.params_from(args) ⇒ Object
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
# File 'lib/cfoundry/v2/model_magic.rb', line 73
def self.params_from(args)
options, _ = args
options ||= {}
options[:depth] ||= 1
params = {}
options.each do |k, v|
case k
when :depth
params[:"inline-relations-depth"] = v
when :query
params[:q] = v.join(":")
end
end
params
end
|
Instance Method Details
#attributes ⇒ Object
48
49
50
|
# File 'lib/cfoundry/v2/model_magic.rb', line 48
def attributes
@attributes ||= {}
end
|
#defaults ⇒ Object
44
45
46
|
# File 'lib/cfoundry/v2/model_magic.rb', line 44
def defaults
@defaults ||= {}
end
|
#inherited(klass) ⇒ Object
60
61
62
63
|
# File 'lib/cfoundry/v2/model_magic.rb', line 60
def inherited(klass)
add_client_methods(klass)
has_summary
end
|
#object_name ⇒ Object
33
34
35
36
37
38
|
# File 'lib/cfoundry/v2/model_magic.rb', line 33
def object_name
@object_name ||=
name.split("::").last.gsub(
/([a-z])([A-Z])/,
'\1_\2').downcase.to_sym
end
|
#plural_object_name ⇒ Object
40
41
42
|
# File 'lib/cfoundry/v2/model_magic.rb', line 40
def plural_object_name
:"#{object_name}s"
end
|
#scoped_to_organization(relation = :organization) ⇒ Object
65
66
67
|
# File 'lib/cfoundry/v2/model_magic.rb', line 65
def scoped_to_organization(relation = :organization)
@scoped_organization = relation
end
|
#scoped_to_space(relation = :space) ⇒ Object
69
70
71
|
# File 'lib/cfoundry/v2/model_magic.rb', line 69
def scoped_to_space(relation = :space)
@scoped_space = relation
end
|
#to_many_relations ⇒ Object
56
57
58
|
# File 'lib/cfoundry/v2/model_magic.rb', line 56
def to_many_relations
@to_many_relations ||= {}
end
|
#to_one_relations ⇒ Object
52
53
54
|
# File 'lib/cfoundry/v2/model_magic.rb', line 52
def to_one_relations
@to_one_relations ||= {}
end
|