slightly improve readability

pull/2550/head
Jan Sandbrink 10 years ago
parent c576641579
commit 518b98b6c6
  1. 30
      lib/api/decorators/schema.rb

@ -30,9 +30,10 @@
module API
module Decorators
class Schema < Single
def self.schema(property,
class << self
def schema(property,
type:,
title: represented_class.human_attribute_name(property),
title: make_title(property),
required: true,
writable: true,
min_length: nil,
@ -51,9 +52,9 @@ module API
writeable: false
end
def self.schema_with_allowed_link(property,
type: property.to_s.camelize,
title: represented_class.human_attribute_name(property),
def schema_with_allowed_link(property,
type: make_type(property),
title: make_title(property),
href_callback:,
required: true,
writable: true)
@ -76,9 +77,9 @@ module API
}
end
def self.schema_with_allowed_collection(property,
type: property.to_s.camelize,
title: represented_class.human_attribute_name(property),
def schema_with_allowed_collection(property,
type: make_type(property),
title: make_title(property),
values_callback:,
value_representer:,
link_factory:,
@ -106,7 +107,18 @@ module API
}
end
def self.represented_class
def represented_class
end
private
def make_title(property_name)
represented_class.human_attribute_name(property_name)
end
def make_type(property_name)
property_name.to_s.camelize
end
end
def current_user

Loading…
Cancel
Save