Skip to content

Commit

Permalink
Move class methods to top to avoid confusion
Browse files Browse the repository at this point in the history
  • Loading branch information
pablobm committed Feb 13, 2020
1 parent 7ac3911 commit 9f465f2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
8 changes: 4 additions & 4 deletions lib/administrate/field/base.rb
Expand Up @@ -20,6 +20,10 @@ def self.field_type
to_s.split("::").last.underscore
end

def self.permitted_attribute(attr, _options = nil)
attr
end

def initialize(attribute, data, page, options = {})
@attribute = attribute
@data = data
Expand All @@ -28,10 +32,6 @@ def initialize(attribute, data, page, options = {})
@options = options
end

def self.permitted_attribute(attr, _options = nil)
attr
end

def html_class
self.class.html_class
end
Expand Down
14 changes: 7 additions & 7 deletions lib/administrate/field/has_one.rb
Expand Up @@ -3,13 +3,6 @@
module Administrate
module Field
class HasOne < Associative
def nested_form
@nested_form ||= Administrate::Page::Form.new(
resolver.dashboard_class.new,
data || resolver.resource_class.new,
)
end

def self.permitted_attribute(attr, options = nil)
associated_class_name =
if options
Expand All @@ -24,6 +17,13 @@ def self.permitted_attribute(attr, options = nil)
{ "#{attr}_attributes": related_dashboard_attributes }
end

def nested_form
@nested_form ||= Administrate::Page::Form.new(
resolver.dashboard_class.new,
data || resolver.resource_class.new,
)
end

private

def resolver
Expand Down
8 changes: 4 additions & 4 deletions lib/administrate/field/polymorphic.rb
Expand Up @@ -3,6 +3,10 @@
module Administrate
module Field
class Polymorphic < BelongsTo
def self.permitted_attribute(attr, _options = nil)
{ attr => %i{type value} }
end

def associated_resource_grouped_options
classes.map do |klass|
[klass.to_s, candidate_resources_for(klass).map do |resource|
Expand All @@ -11,10 +15,6 @@ def associated_resource_grouped_options
end
end

def self.permitted_attribute(attr, _options = nil)
{ attr => %i{type value} }
end

def permitted_attribute
{ attribute => %i{type value} }
end
Expand Down

0 comments on commit 9f465f2

Please sign in to comment.