lib/haveapi/go_client/resource.rb in haveapi-go-client-0.20.0 vs lib/haveapi/go_client/resource.rb in haveapi-go-client-0.21.0
- old
+ new
@@ -46,11 +46,11 @@
@go_type = full_go_type
@resources = desc[:resources].map do |k, v|
Resource.new(self, k, v)
end.sort!
@actions = desc[:actions].map do |k, v|
- Action.new(self, k.to_s, v, prefix: prefix)
+ Action.new(self, k.to_s, v, prefix:)
end.sort!
end
# @return [ApiVersion]
def api_version
@@ -76,20 +76,20 @@
def resource_path
parent_resources + [self]
end
def resolve_associations
- actions.each { |a| a.resolve_associations }
- resources.each { |r| r.resolve_associations }
+ actions.each(&:resolve_associations)
+ resources.each(&:resolve_associations)
end
def generate(gen)
ErbTemplate.render_to_if_changed(
'resource.go',
{
package: gen.package,
- resource: self,
+ resource: self
},
File.join(gen.dst, prefix_underscore("resource_#{full_name}.go"))
)
resources.each { |r| r.generate(gen) }
@@ -97,11 +97,11 @@
actions.each do |a|
ErbTemplate.render_to_if_changed(
'action.go',
{
package: gen.package,
- action: a,
+ action: a
},
File.join(gen.dst, prefix_underscore("resource_#{full_name}_action_#{a.name}.go"))
)
end
end
@@ -109,10 +109,11 @@
def <=>(other)
go_name <=> other.go_name
end
protected
+
attr_reader :prefix
def prefix_underscore(s)
if prefix
"#{prefix}_#{s}"
@@ -131,9 +132,9 @@
def full_go_type
names = ['Resource']
names.concat(parent_resources.map(&:go_name))
names << go_name
- prefix_camel(names.join(''))
+ prefix_camel(names.join)
end
end
end